I've done a bit of scripting in Bash in one of my classes but I'm pretty much completely new to batch scripts. I would like to run the following command from a batch script:
java -cp "C:\path to external jar;C:\Path to Java project bin" main.MP3Edit [-p path_to_target_dir] [File1 ...]
by allowing the user (me) to input the path to target directory and the file names into the command prompt terminal (yes, I could read the input in the Java program itself but let's say I'm running someone else's program and can't change it).
I've written the following batch script using a few things I found on Google:
set /p "arg=Input the path to target directory (defaults to current directory if left empty): "
if not [%arg%]== set "arg=-p %arg%"
echo Input file names one per line. If no file names are input, all files in the target directory will be used.
set /p "line=Input next file name (leave empty to end list of files): "
if [%line%]== goto run
set "arg=%arg% %line%"
REM java -cp "C:\path to external jar;C:\Path to Java project bin" main.MP3Edit %arg%
Now the problem with this is that the path and the file names can have spaces in them, which means each of them should in the command be surrounded by quotation marks. In bash iirc you can achieve that by using a combination of single quotes and double quotes in the script, but single quotes don't seem to do anything in batch. How do I get each argument separately properly surrounded by quotation marks?
Also incidentally, is there a way to make set /p recognize an empty string as an input? Because in the above example, if I remove the "set line=" command, the loop doesn't exit even on empty input because the set /p (first line of the loop) doesn't seem to do anything if it receives empty input.
...and that's the bottom line because Mate de Vita said so.