Link to home
Start Free TrialLog in
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.
Avatar of Kurt4949
Kurt4949
Flag of United States of America image

Try something like this

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

ASKER

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.
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.*
Avatar of gram77

ASKER

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.*
Remove-Item C:\Users\Me\Pictures\* -include *_1.*
Avatar of gram77

ASKER

First of all i would want to see what file windows is selecting to delete, and then delete them
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
Avatar of Kurt4949
Kurt4949
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial