Link to home
Start Free TrialLog in
Avatar of Brad Murphy
Brad Murphy

asked on

Software that will scan specific folders and delete word/excel files older than 5 years of age

I'm looking for an application that can run on Server 2012r2 that will list all files in specific folders (and subfolders).  I want to delete all Word/Excel files 5 years of age and older out of our client directory.  (Yes we have backups)

Thank you!
Avatar of arnold
arnold
Flag of United States of America image

Unix utils find can do that, though I would seriously advise you consider archiving the files for later access versus outright deletion.
Scripting this using powershell or vbscript .....
Robocopy can be used to /mov files from these locations to another ...........based on age of file
You can then decide to run a delete on that folder .............before running the new robocopy .

I've not looked at whether there is a specific software to do that in either open source or commercial...
ASKER CERTIFIED SOLUTION
Avatar of Shaun Vermaak
Shaun Vermaak
Flag of Australia 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
This powershell code works
# list 5 year old files to OldFiles.csv
Get-ChildItem "C:\specificfolder" -Recurse | Where-Object {$_.LastWriteTime -lt (get-date).AddYears(-5)} | Select-Object FullName, LastWriteTime | Export-Csv OldFiles.csv

Open in new window


# Delete files listed in OldFiles.csv.
# Remove -WhatIf to do it for real
Get-ChildItem "C:\specificfolder" -Recurse | Where-Object {$_.LastWriteTime -lt (get-date).AddYears(-5)} | Remove-Item -Force -whatif

Open in new window

Shaun's code at ID: 42097780 doesn't work. Nothing happens. LOL.
Glad we could help.

@OP, experts and future visitors:
Please remember to endorse my, or any other expert's comments that you found helpful by clicking on the "Thumb's Up" button

Read more on endorsements
https://www.experts-exchange.com/discussions/218503/What-are-Endorsements.html
@NVIT: You know your command deletes all files irrespective of file-type? For my command it to show/do something you need to have an XLSX, DOCX in C:\Temp that is older than 5years
@Shaun

At least it works. And the -WhatIf switch is there for safety.

Easy enough to fix... Just add the -Include *.docx, *.xlsx and it's covered.

In contrast... Your code DOES NOT do anything. No result is echoed by WhatIf. I guess you didn't test it.
Easy enough to fix... Just add the -Include *.docx, *.xlsx and it's covered.
Wonder where you got that from.... Maybe ID: 42097780
I just need to change creation time to last write time
Seems unnecessary, the examples are there to get the asker started. The asker choose the answer that works for them.
Exactly...
Whatever