Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top
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? – Sam Axe 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
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


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.