Link to home
Start Free TrialLog in
Avatar of ITMcmcpa
ITMcmcpaFlag for United States of America

asked on

Move files based on an Excel list

I have a repetitive task each month to move files from one location to another based on the file name.  In this case, we have a PDF file that has a name of a person.  Example: Doe, John (1234).pdf
I would like to create an Excel list that has two columns.  The first column would have the name of the destination folder and the second column would have the name of the file.  The name of the file never changes, only the content of the file for that user.  There are about 200 files that will be moved during each session.
Column A = Folder name- JohnD
Column B = File name- Doe, John (1234).pdf

I would like to find a script that will loop through each file in the origin folder
Get the file name
Lookup the file name in the Excel list
If the file name is found, get the destination path/folder from the matching column
Move the found file to the destination folder
Overwrite the file in the destination if it exists
Delete the original file

Any suggestions?
ASKER CERTIFIED SOLUTION
Avatar of Justin Ellenbecker
Justin Ellenbecker
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ITMcmcpa

ASKER

Thank you very much for the quick response.  This worked very well.  I made a slight adjustment to delete the source file and it does exactly what I needed.

oFS.DeleteFile ("C:\sourcepath\" & file.name)

Thanks again!