Avatar of gram77
gram77Flag for India asked on

windows powershell to delete files

I want a windows powerschell script to delete all files with names ending with _1.
Microsoft Legacy OSMicrosoft Applications

Avatar of undefined
Last Comment
Kurt4949

8/22/2022 - Mon
Kurt4949

Try something like this

PS C:\temp> remove-item * -include *_1.*
ASKER
gram77

Where do i run this command.
I run it in cmd.

I get error:
'Remove-Item' is not recognized as an internal or external command,
operable program or batch file.
Kurt4949

You need to run it in powershell.  Click start and in the search box, type powershell.

Another example with folder name: remove-item c:\Temp\* -include *_1.*
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
ASKER
gram77

Incidently the script didn't do anything
Remove-Item -path "C:\Users\Me\Pictures" -include *_1.*

or

Remove-Item -path 'C:\Users\Me\Pictures' -include *_1.*
Kurt4949

Remove-Item C:\Users\Me\Pictures\* -include *_1.*
ASKER
gram77

First of all i would want to see what file windows is selecting to delete, and then delete them
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
Kurt4949

If you have a space in your username then follow this example.

PS C:\> remove-item "C:\Temp\New Folder\*" -include *_1.*

You could just create a test folder and add a few files like I did in my example.
ASKER CERTIFIED SOLUTION
Kurt4949

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question