I would like my script to fetch certain files from within multiple directories (location).
For Example:
Set 1:
Following files from C:\test\ext
20160830.ext -- (CurrentDate - 1).ext
20160823.ext -- (CurrentDate - 7).ext
20160802.ext -- (CurrentDate - 28).ext
Following file from C:\test\nxt
20160830.nxt -- (CurrentDate - 1).nxt
Set 2:
Following files from C:\test2\ext (These files have a prefix before the name)
IND20160830.ext -- (INDCurrentDate - 1).ext
IND20160823.ext -- (INDCurrentDate - 7).ext
IND20160802.ext -- (INDCurrentDate - 28).ext
Following files from C:\test2\nxt
IND20160830.nxt -- (INDCurrentDate - 1).nxt
I have got the current date converted into yyyymmdd format using the following command
$Curr_date = (get-date).ToString('yyyyMMdd')
Output: 20160831
But I am unsure how to fetch the files as per conditions listed above from those directory as its got to be dynamic as the script will be schedule to run weekly and should fetch the files as per the above condition.