Page 1 of 1

need help in adding a word at the end of all files

Posted: 15 Aug 2018 09:46
by lalat06bag
Hi,

I have few files in a folder. Just want to rename all and add test at the end of the file. Can any one please see this?
existing file name xyz.txt, abc.txt
want to rename as xyz_test.txt, abc_test.txt

Thanks,

Re: need help in adding a word at the end of all files

Posted: 15 Aug 2018 10:46
by aGerman
Something like that should work:

Code: Select all

for /f "delims=" %%i in ('dir /a-d /b *.txt') do ren "%%i" "%%~ni_test%%~xi"
Steffen

Re: need help in adding a word at the end of all files

Posted: 15 Aug 2018 13:16
by lalat06bag
Thank you!

Re: need help in adding a word at the end of all files

Posted: 15 Aug 2018 18:29
by Squashman
You have been shown in your previous questions how to separate the file name from the file extension. Please do a little research of your own before asking questions.