rename multiple files using command prompt

general command to rename extensions of multiple files using command prompt in windows is
ren *.html *.txt

but if i want to rename a file from something like below to
ABC_4739874_2349827.txt
to
ABC_4739874_2349827_RENAMED.txt

how can i do that.

Thanks
shragiAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

NVITEnd-user supportCommented:
for %A in (*.txt *.html) do ren %~nA_RENAMED%~xA
0
Joseph DalyCommented:
Using powershell.

$dir = "C:\filepath"
gci $dir | foreach {
$name = $_.name
$newname = $name+"_renamed"
rename-item $dir\$name $newname
}

Open in new window

0
Jonathan BriteSystem AdminCommented:
You can use wild cards in command line with rename.  I am pretty sure your example would be (without quotes) "rename ABC_*.txt ABC_*_RENAMED.txt"  

I also think Josephs PS script would be much cleaner, especially if going through multiple directories)
0
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

shragiAuthor Commented:
@NewVillageIT
I got error saying "the syntax of the command is incorrect"
for %A in (*.txt) do ren %~nA_RENAMED%~xA
0
Jonathan BriteSystem AdminCommented:
have you tried a normal rename command like I listed above yet? (be sure to test it before trying it globally)
0
NVITEnd-user supportCommented:
Correction to my CMD version:
for %A in (*.txt *.html) do ren "%A" "%~nA_RENAMED%~xA"

Open in new window

0
NVITEnd-user supportCommented:
To rename in disparate folders:
for %A in (c:\dir1\*.txt c:\dir2\*.txt) do ren "%A" "%~nA_RENAMED%~xA"

Open in new window


To rename in current and sub-folders:
for /r %A in (*.txt *.html) do ren "%A" "%~nA_RENAMED%~xA"

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
shragiAuthor Commented:
@Jonathan Brite

your command is not working - it is renaming wrongly
ABC_4739874_2349827.txt is renamed to ABC_4739874_RENAMED.txt
but i want it to be renamed to
ABC_4739874_2349827_RENAMED.txt
0
Jonathan BriteSystem AdminCommented:
Thanks NewVillageIT.  That helped me as well.
0
shragiAuthor Commented:
thanks newvillageIT :)
0
NVITEnd-user supportCommented:
I'm glad it worked for you, shragi, and Jonathan. Have a nice day...8-)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows OS

From novice to tech pro — start learning today.