Batch: Check for space in filename

November 30, 2011 at 13:20:05
Specs: Windows 7
Hey guys
I was wondering if it's possible for a batch script to check whether a filename contains spaces or not? If spaces is contained in the filename, the script should put "" around the filename. If no spaces is contained, the script should not put "" around the filename.
I'm currently making my first batch file ever (you have to start somewhere, right?), and I really need such a script.

See More: Batch: Check for space in filename

Report •

November 30, 2011 at 13:31:37
Why not just put quotes round the filename anyway?

Report •

November 30, 2011 at 14:07:03
I'm using the batch script to convert wav files to m4a via a file called faac.exe.
If i put brackets around the filename (like this: D:\faac "%D%.wav" -w -q 500 -o %D%.m4a) it says "Cannot encode several input files to one output file".
I don't know exactly why, because when I'm converting without this script it works fine with the brackets.

But as I already said this is my first batch script, so I may have written something wrong?
The code for the non-working section looks like this:

set filename=%filename%
set /P D=Insert the name of the file you want to convert:
D:\faac "%filename%.wav" -w -q 500 -o %filename%.m4a
goto menu

(The third line is options from faac.exe, I'm sure these are right. So if something isn't right, it must be somewhere in the batch part.)

Report •

Related Solutions

Ask Question