Humberto Freitas
Humberto Freitas

Reputation: 483

Using command line rename files based on a list

I'm using it command to rename some files, the point is que When I try usalo through the script does not work, something que does not Occur in batch.

Set oShell = WScript.CreateObject("WScript.Shell") 
oShell.Run("cmd.exe /C For /f ""usebackq delims="" %%a in (""C:\MY FILES\LIST.txt"") do (If Exist ""%%a"" Ren ""%%a"" ""*.txt"")"), 1, True

. List:

"A\a1.ini"
"A\a1_1.ini"
"A\a2.log"

Upvotes: 0

Views: 114

Answers (1)

MC ND
MC ND

Reputation: 70923

Your for /f loop is not running inside a batch file, but in command line context, a direct command inside a cmd instance.

for replaceable parameters are written as %a, and the percent sign needs to be escaped doubling it (%%a) when used inside a batch file. But as indicated this is not your case.

Upvotes: 1

Related Questions