Hi Guys
You have previously help me with some code that I needed, without me having a wast knowledge about PowerShell.
So I am hoping you can do it again. ![]()
I am looking to make a script that can help me clean up folders containing files that are generated daily going back to 2016, there are now millions of files pr. folder. And therefore I can either make a simple script that can find files containing part of the file name and then compressing those files and move them.
But if I wanted to compress and move files for each month going back to 2016, and this needs to be done on a lot of folders, each month. I would normally do this by manually typing in (finding all files _201601.csv) and next (find all files _201602.csv) and so on for all month all years going back.
I was hoping to automate this process ![]()
- Find a year & month in a filename -> in this case 20180802 ( File -> 0016000449_00168737_valuereport_20180827104607_2105.csv)
- Use 201808 to find all files containing *201808* in a specific folder.
- Compress these files and move them, thereafter delete them.
But I know how to do that. So what I need is for Powershell to:
- Do the above action, by year&month automatically. Powershell should find all 201808 files, compress/move, and move on to 201809. repeat for 201810 and then on and on until the folder almost is empty.
- Reson, why I write almost, is that I only need to this action for all files that are older than 90 days (3 months) so something like <=today()-90