Simple Batch File...

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
vegenigma
Posts: 1
Joined: 09 Dec 2011 13:27

Simple Batch File...

#1 Post by vegenigma » 09 Dec 2011 13:33

Hello,

I have a batch file that only contains the following commands:


FOR %%G IN (*.flac) DO "C:\Program Files (x86)\FLAC\metaflac.exe" --remove-all-tags "%%G"
FOR %%G IN (*.flac) DO "C:\Program Files (x86)\FLAC\TAG.exe" -f "Cuesheet=%~dpnG.cue" "%%G"
move *.flac C:\Users\SG\Music\CompletedFLACs
move *.cue C:\Users\SG\Music\CompletedFLACs

When I run the batch file I get these errors:


C:\Users\SG\Music\IncompleteFLACs>FOR %G IN (*.flac) DO "C:\Program Files (x86)\FLAC\metaflac.exe" --remove-all-tags "%G"

C:\Users\SG\Music\IncompleteFLACs>"C:\Program Files (x86)\FLAC\metaflac.exe" --remove-all-tags "ABC - 123.flac"
The following usage of the path operator in batch-parameter
substitution is invalid: %~dpnG.cue" "%%G"

For valid formats type CALL /? or FOR /?
The syntax of the command is incorrect.
C:\Users\SG\Music\IncompleteFLACs>FOR %G IN (*.flac) DO "C:\Program Files (x86)\FLAC\TAG.exe" -f "Cuesheet==%~dpnG.cue" "%%G"



When I put each command by itself in 3 separate batch files, it runs perfectly without error.

Can someone please explain why it runs without error when run individually but with all commands in a batch file, I get these errors?

Thanks,
SG

dbenham
Expert
Posts: 2461
Joined: 12 Feb 2011 21:02
Location: United States (east coast)

Re: Simple Batch File...

#2 Post by dbenham » 09 Dec 2011 13:43

You are missing a % so it is trying to interpret a numbered parameter instead of an alpha FOR variable.

FOR %%G IN (*.flac) DO "C:\Program Files (x86)\FLAC\TAG.exe" -f "Cuesheet=%%~dpnG.cue" "%%G"


Dave Benham

Post Reply