Currently report files for multiple customers are placed in a source folder monthly. These report files include the customer name and need to be uploaded a for each customer in a subfolder named “Backup Controle” of their own folder.
Notes:
- The customer’s root folder name can differ from the customer name used in the report files.
- The folder “Backup Controle” isn’t always located in the same relative location from the root folder
Example:
- The source report files folder contains:
- Backup Controle – Customer 1 – 12-2012.pdf
- Backup Controle – Customer 2 – 12-2012.pdf
- The customer’s root folder’s might be:
- C:\Customersroot\Cust1
- C:\Customersroot\Client2
- The “Backup Controle” folder might be located at:
- C:\Customersroot\Cust1\folder1\folder2\folder3\temp\folder4\Backup Controle
- C:\Customersroot\Client2\folder1\folder2\Backup Controle
This action was performed manually at first using the SharePoint web interface to browse to each customer’s folder and upload the report. This is ofcourse not the type of work you want to do. Using the SharePoint WebDAV you can perform this using Explorer and drag and drop, which would make it a bit more bearable.
It would however be even better if it could be automated and that’s just what we did with this script. The script contains a function where you can define for each customer:
- Which name filter specifies the customer for the report name. B.e. : “Customer 1” or “Customer 2”
- What the name of the folder is for the customer’s root folder. B.e. : “Cust1” or “Client2”
The script will then recursively look inside the customer’s folder for a folder matching the “Backup Controle” folder and will copy the report to it (assuming the report is not already there).
In this example you would call the function like this:
- Copy-FileMatchingFilterToCustomerFolder “Customer 1” “cust1”
- Copy-FileMatchingFilterToCustomerFolder “Customer 2” “client2”
Note: It is assumed that there is only one folder named “Backup” Controle in the customer’s folder.