I receive a series of directories every month that contain PDF files showing various customer product use statistics for the previous month. Each file name starts with a “Testing Center” ID that precedes a dash (“-“) followed by other information about the report type, date, etc.
I have created a series of folders for each customer and named them based on Customer ID. I need to move each testing center report into its customer folder.
My initial research on the subject has provided me with a few PowerShell scripts that will move files based on their name but I need to take this a step beyond that. I need the script to be able to look at a list (.csv or .txt) to tell it which testing center ID belongs to which customer ID and then move the file that customer’s folder:
So, the steps of my ideal script seem to be the following:
- Go to the first file in the current directory.
- Evaluate the portion of the file name to the left of the first dash (“-“) and record that value as “Testing Center ID”.
- Look up that value on the mapping file and:
- If it is found on the mapping file (column 1 will list “Testing Center ID”), move it to the destination folder, named after the “Customer ID” (column 2 will list “Customer ID” for each “Testing Center ID”).
- If it is not found, the file should be skipped and not moved.
- Move on to the next file in the current directory, exit script after last file evaluated.
Ideally, I’d like to be able to use this script across several different directories. The files in each directory, while containing different types of reports, are all named the same way (Testing Center ID is always listed before the first dash).
I realize that I shouldn’t just be asking for a blanket solution but there are a few concepts in the process I described above that I’m not sure how to even search for. What sort of concepts should I be searching for in either the Script Repository or these forums to better enable me to adapt an answer from what is already posted?
Thanks in advance for your help!