I have numerous files in a very complex directory structure, and for reasons not worth discussing I need to rename all files with the extension of \".inp\" to have \".TXT\" exte
for /r startdir %%i in (*.inp) do ECHO ren "%%i" "%%~ni.txt"
should work for you. Replace startdir
with your starting directoryname and when you've checked this works to your satisfaction, remove the echo
before the ren
to actually do the rename.
For the downvoters: executing a batch file differs from excuting from the command prompt in that each %%x
where x
is the metavariable (loop-control variable) needs to be reduced to %
, so
for /r startdir %i in (*.inp) do ECHO ren "%i" "%~ni.txt"
should work if you execute this from the prompt. Please read the note about echo
.