Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.
for /r %%G in (*_abc.txt) do ren "%%~G" *_abc_xyz.txt

I keep getting this error: %%G was unexpected at this time.

share|improve this question
    
what scripting language? –  Dan-o Jan 28 '13 at 2:50
    
Looks to be windows .bat file –  slm Jan 28 '13 at 3:00
    
yes, for batch file to run from command line - windows –  user193307 Jan 28 '13 at 3:49

1 Answer 1

up vote 0 down vote accepted

FOR variables use a single % when run from the command line, and double %% when within a batch script.

So to run on the command line, you need:

for /r %G in (*_abc.txt) do ren "%G" *_abc_xyz.txt
share|improve this answer
    
that worked! Thanks a lot! –  user193307 Jan 28 '13 at 5:35

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.