rename mulitple files

I have a bunch of files named like this that I'd like to remove the " - Shortcut" part from.  Is it possible to do this with the rename command?
d224241 - Shortcut.lnk
d22433ad1 - Shortcut.lnk
d224a - Shortcut.lnk
JohnPaddockAsked:
Who is Participating?
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.

oBdACommented:
PowerShell in test mode; remove the -WhatIf to run it for real:
gci 'C:\Temp\*.lnk' | ren -NewName {$_.Name -replace ' - Shortcut', ''} -WhatIf

Open in new window

1
Bill PrewCommented:
And if you want to do it with just DOS commands, it can't be done easily with a single command line, but here's a small BAT file that would do the job.  Place into the folder where the files are, change to that directory at a command prompt, and run it.

@echo off
setlocal EnableDelayedExpansion
for %%A in ("* - Shortcut.lnk") do (
    set Name=%%~nA
    set Name=!Name: - Shortcut=!
    ren "%%A" "!Name!.*"
)

Open in new window


»bp
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
JohnPaddockAuthor Commented:
thanks
0
Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

JohnPaddockAuthor Commented:
Can I not select 2 solutions anymore.  I'd select both if I could
0
JohnPaddockAuthor Commented:
I used the batch file and it worked well.  Thankyou.  I'm sure I've done that before with one command-line.  If you happen to know how, I'd be curious, but don't really need to know anymore.  I'm trying to figure out how to accept the powershell solution as a solution also.  thankyou for that one as well
0
oBdACommented:
It's gotten pretty convoluted, in my opinion - you either need to use the "Was this helpful" boxes, or switch to "Classic View".
With the "Report Question" link below your question, you can notify a moderator to re-open the question.
How do I close my question?
http://support.experts-exchange.com/customer/portal/articles/2527982
0
JohnPaddockAuthor Commented:
ok done.  I wasn't aware of classic view.  thanks guys.  much appreciated
0
Bill PrewCommented:
Welcome.


»bp
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.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.