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" extensions. There are numerous other files with other extensions that I do not want to be touched, and I want to do it recursively down at least 5 levels.
So far I have:
for /d %%x in (*) do pushd %%x & Ren *.inp *.TXT & popd
...but this only goes down one level of directories.
Can anyone help? Thanks in advance!
On Windows 7, the following one-line command works for me, to rename all files, recursively, in *.js to *.txt:
John Smith's answer is excellent, and it works. But to be completely clear (I had to re-read magoo's notes to figure out the correct syntax), here is exactly what you need to do...
Up vote their responses, I am but a lowly formater...
should work for you. Replace
startdir
with your starting directoryname and when you've checked this works to your satisfaction, remove theecho
before theren
to actually do the rename.For the downvoters: executing a batch file differs from excuting from the command prompt in that each
%%x
wherex
is the metavariable (loop-control variable) needs to be reduced to%
, soshould work if you execute this from the prompt. Please read the note about
echo
.