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
Who is Participating?

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

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.

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

Bill PrewIT / Software Engineering ConsultantCommented:
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


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:
C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

JohnPaddockAuthor Commented:
Can I not select 2 solutions anymore.  I'd select both if I could
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
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?
JohnPaddockAuthor Commented:
ok done.  I wasn't aware of classic view.  thanks guys.  much appreciated
Bill PrewIT / Software Engineering ConsultantCommented:

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.