windows - Rename filename using another files name from the same folder with FOR loop -
if found helpful batch script @ rename filename using files name same folder
it works:
@echo off setlocal enabledelayedexpansion :: assumes there 1 avi file in folder /f %%a in ('dir /b *.jpg') ( set basename=%%~na ren *.avi !basename!.avi )
but how can add additional loop every subfolder. have many subfolders require renaming. problem is, after renaming first name of filename taken. after space in file name script cuts file name.
the structure follows:
folder ------------subfolder ---------------------file.jpg ---------------------notagoodfilename.avi
after batchscript:
folder ------------subfolder ---------------------file.jpg ---------------------file.avi
this script should work every subfolder. folder --> subfolder, subfolder1 ...
thanks help!
your previous script simplified following one-liner:
for %%a in (*.jpg) ren *.avi %%~na.*
to in subfolders of current folder:
for /r %%a in (*.jpg) ren %%~dpa*.avi %%~na.*
update: following comments answer, here's better version:
for /r "c:\path\to\top\folder" %%a in (*.jpg) ren "%%~dpa*.avi" "%%~na.*"
Comments
Post a Comment