Thank you for being a valued part of the CNET community. As of December 1, 2020, the forums are in read-only format. In early 2021, CNET Forums will no longer be available. We are grateful for the participation and advice you have provided to one another over the years.

Thanks,

CNET Support

Question

padding zeros in filename number - cmd batch file

Jul 30, 2012 1:53AM PDT

Hi. I have a for loop, which calls a program (tc), which outputs variouis files. I would like to rename files with numbers at the end, with 3 figures.

e.g. filename_001
...
filename_197

So far I have the following:

for /l %%i in (1,1,197) do (
tc C:\filename.inp "macro Range {%%i} #define GUI_LINES"
copy C:\filename.out C:\subfiles\filename_%%i.inp
move /y C:\filename.out C:\filename.inp
move /y C:\filename_%%i.xy C:\subfiles\filename_%%i.xy
)

This only gives me

e.g. filename_1
...
filename_197

Can anyone help me get the padding zeros please?

Thanks

Discussion is locked

- Collapse -
Answer
Did you try prior discussions?
Jul 30, 2012 2:17AM PDT
- Collapse -
re: did you try prior discussions?
Jul 30, 2012 5:55PM PDT

I have tried other forums and searches. To be honest I am a complete novice, who gets confused by what even echo REN means. I'll try and work out what the suggestions on your link do, and how I can apply it to my problem.

Thanks