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

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
lalat06bag
Posts: 51
Joined: 10 Jan 2018 15:21

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

#1 Post by lalat06bag » 15 Aug 2018 09:46

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,

aGerman
Expert
Posts: 4654
Joined: 22 Jan 2010 18:01
Location: Germany

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

#2 Post by aGerman » 15 Aug 2018 10:46

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

lalat06bag
Posts: 51
Joined: 10 Jan 2018 15:21

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

#3 Post by lalat06bag » 15 Aug 2018 13:16

Thank you!

Squashman
Expert
Posts: 4465
Joined: 23 Dec 2011 13:59

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

#4 Post by Squashman » 15 Aug 2018 18:29

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.

Post Reply