i have a directory "C:\Main" and within the directory several others "C:\Main\1" C:\Main\2" ect.. In each numbered directory there are 2 image files. Each directory structure is the same, meaning there in only 1 directory and always only 2 images in each. Can i make a batch file to go into "C:\Main" and rename all images in sub directories"1" "2" "3" ect.. to 0 and 1. so i want to end up with
C:\Main\1\0.png
C:\Main\1\1.png
C:\Main\2\0.png
C:\Main\2\1.png
C:\Main\3\0.png
C:\Main\3\1.png
ect ect..
is this possible?? thanks..
batch file to rename files
Moderator: DosItHelp
Re: batch file to rename files
What are the files called now?
Does it matter in which order they are renamed - if the filenames aren't constants?
Does it matter in which order they are renamed - if the filenames aren't constants?
-
- Posts: 19
- Joined: 23 Jul 2013 12:45
Re: batch file to rename files
no, the 2 images within each folder are exactly the same. i just need 2 copies of the same image, so it doesn't matter which one is 0 or which one is 1.
Re: batch file to rename files
Code: Select all
@echo off
for /d /r "C:\Main" %%a in (*) do (
pushd "%%a"
for %%b in (*.png) do (
if not exist 0.png ren "%%b" 0.png
if not exist 1.png ren "%%b" 1.png
)
popd
)