0

I know this question has been asked several times, but I'm having issues getting it working. I'm a noob when it comes to programming so borrowing code is about the most I can do. I need a script that can delete files that are in a folder that are X days old, but also need to only delete ones that contain "XXX" in the file names. They have no file extensions. I've seen a couple scripts on here that delete by date, and/or file extension but cant seem to get it working where it looks for certain characters. If anyone could help me out I would forever be in your debt.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129

1 Answers1

2

This may be one of the questions that you viewed: Delete files older than 15 days using PowerShell

If you use one of the listed solutions that uses Get-ChildItem to get files of a specified age, add -Filter *XXX* to the Get-ChildItem command to limit the results to files that contain "XXX" in the file name.

Community
  • 1
  • 1
David
  • 36
  • 4
  • I did see that script but Im having issues getting that one to delete any files that are not set to 0 days. The files have a date modified of 2011 so they plenty old enough for the script. Im moving the files to a new folder for testing but they are not deleting, with just that script. – user1210394 Feb 09 '15 at 22:50