Avatar of fireguy1125
fireguy1125
 asked on

Script to Copy and Rename an Excel file Between Network Shares

I have an XLS file that is updated once a day on a network share. The network share is \\company.com\Reports\Daily
The file name is a randomly generated file name with an *.xls extension.

I need a script that I can setup as a daily scheduled task that will:

-Take the *.xls file with the most recent last modified date located in: \\company.com\Reports\Daily folder
-Rename that file to the name: active.xls
-Copy that file to a location in: \\ServerName\Reports with the name Active.xls
(The order of bullet points 2 or 3 does not matter, the end result of the script just requires that I have the latest version of the *.xls file on the specific server with the name Active.xls)

The reason for this is I have an application at the destination server that calls for this specific file name, so in order to completely automate this process without having to manually rename the file every day, I would like this in a scheduled task script.

Thank you.
Windows Server 2008PowershellScripting Languages

Avatar of undefined
Last Comment
fireguy1125

8/22/2022 - Mon
Steven Carnahan

Couple questions:

1. Will the task run once or multiple times during the day?
2. Is there a possiblity that the destination file (active.xls) be in use/open when the task runs?
ASKER CERTIFIED SOLUTION
footech

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
fireguy1125

ASKER
1. The task will run once per day, and there will not be more than one modified source file per day.
2. Destination file will not be in use.
Steven Carnahan

Are the source and destination mapped locations?
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
fireguy1125

ASKER
They are not mapped, but are shared and accessible via UNC paths as noted.
fireguy1125

ASKER
Works perfectly, thanks!