Batch Script to Rename file and add number

July 14, 2011 at 03:14:14
Specs: Windows XP
Hi Everyone,

I have 500 files coming in and I need to first check if any file(s) exist then rename all of them regardless of what their filename is (the files are named in a different language).

No need to process them in any order.


1. “¦X¼d¬f-20110703-¦+¦dñHÑ-ª-¦=¬¦.xls”
2. “¦X¼d¬f-20110707-¦+¡¦-+¡8.xls”
3. “¦X¼d¬f-20110707-¦+¡¦ñj¦«.xls”
4. “¦X¼d¬f-20110708-¦+¡¦¬M¼n.xls”
5. “¦X¼d¬f-20110713-¦d¼O¼n¦hÑP.xls”



Hope you could help me on this one. I’ve been trying to do this for weeks.


See More: Batch Script to Rename file and add number

Report •

July 14, 2011 at 13:16:58
Weird Filenames
Will this help any

@echo off
SetLocal EnableDelayedExpansion

set Num=1
for %%a in (*.xls) do (
ren %%a TWN_CH_INV_VISIT_FORM_!Num!.xls
set /a Num+=1

dir *.xls

Report •

July 18, 2011 at 20:43:32
Thanks dtech10!

However, your script renamed "some" of the files but not all of them.

Out of 14, only 8 got renamed.

Report •
Related Solutions

Ask Question