This topic contains 4 replies, has 3 voices, and was last updated by
August 29, 2019 at 7:58 am #173491
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.
Simple enough, if I just want to do this, I could manually change the date for each month going back to 2016.
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
I know I am asking a lot, but maybe some links for other similar questions, or solutions would also be helpful.
I just haven´t been able to find a similar question for this specific need on Google.
August 29, 2019 at 8:04 am #173494ParticipantTopics: 1Replies: 1530Points: 2,591Rank: Community Hero
We're used to be better when we get something to tweak. What do you have so far? Please show you code. Powershell.org is not a free code writing service – you know that, right? We expect you to do your own research before and at least try to solve your problem by yourself.
August 29, 2019 at 8:07 am #173497
That is fair enough, did not know how much I could ask you guys for help.
Hang on and I will get back with something that makes more sense, and with research, time put into it 🙂
September 4, 2019 at 12:14 am #174436ParticipantTopics: 0Replies: 100Points: 363Rank: Contributor
Just following up to determine if you have figured out the solution or you still need assistance.
September 4, 2019 at 11:28 am #174523
Thank you for the followup.
I found another solution and did not know how to remove or close this ticket.
You must be logged in to reply to this topic.