I’ve been tasked with trying to automate a task at work, because we’ve had issues lately with people remembering to do it.
In general, here’s what I need a script to do:
- Get the date of the previous day, in the format YYYYMMDD
- Enter a folder with that given name
- Search within all the folders underneath that location for 4 specific files
- Copy those files to several different locations
The issue I’m having is that, for the 4 files I’m looking for, they’re located in 2 different folders. 3 in 1, 1 in the other. The names of these folders changes daily, depending on what queue they got put into when generated by some other software. I need these files to be moved so that another script can be run on them. I’m having trouble figuring out how to accomplish this. Anyone have some ideas?
If the folders containing the interesting files are subfolders of your dated directory, you can use a nested loop:
output:
A full recursive walk would be a bit more complex, so say so, if you need it.
Just for fun: a recursive version:
output:
(*) as soon as the permission problem is solved.