kalinkula
kalinkula

Reputation: 3

Keep only part of Filename in BATCH

with respect to this question, i am trying to adjust the suggested script to changed needs but am failing. Here is the context:

Thanks a lot!

Upvotes: 0

Views: 79

Answers (1)

rojo
rojo

Reputation: 24466

On the innermost for /F loop, change "%%A" to "%%~A" or "%%~fA". As-is, your filenames containing spaces are populating %%A with quoted results. Therefore, for /F is probably trying to execute something like this:

findstr /I "vVariable" ^<""Worker FFM Generator.qcc.2018""

... which is incorrect. Adding the tilde will strip the inner quotes if present, keeping your explicit quotes valid.

For future reference, using @echo on can help you track down simple bugs such as this, letting you see where the script doesn't behave as expected.

If your script does not live in the same directory as your log files, you should also add pushd directoryname below @echo off, putting the name of the directory containing "Worker FFM Generator etc." in place of directoryname. If you need the script to search files recursively, add the /S switch to findstr.

Upvotes: 2

Related Questions