recursion - Mass rename of file extensions recursively (windows batch) -


i have numerous files in complex directory structure, , reasons not worth discussing need rename files extension of ".inp" have ".txt" extensions. there numerous other files other extensions not want touched, , want recursively down @ least 5 levels.

so far have:

for /d %%x in (*) pushd %%x & ren *.inp *.txt & popd 

...but goes down 1 level of directories.

can help? in advance!

for /r startdir %%i in (*.inp) echo ren "%%i" "%%~ni.txt" 

should work you. replace startdir starting directoryname , when you've checked works satisfaction, remove echo before ren rename.


for downvoters: executing batch file differs excuting command prompt in each %%x x metavariable (loop-control variable) needs reduced %, so

for /r startdir %i in (*.inp) echo ren "%i" "%~ni.txt" 

should work if execute prompt. please read note echo.


Comments