Link to home
Start Free TrialLog in
Avatar of Luis Diaz
Luis DiazFlag for Colombia

asked on

Vb Script/Bat: remove-copy files based on reported files name in a csv file

Hello experts,

I am looking for a script that:

1. Remove all the files in a result folder, modified in the last 5 minutes and which finished with a _V2" string.

2. Open a Listing.csv  file located in the same folder of the script.

3. Read the files names reported in this Listing.csv

4. If a reported file exists in result folder copy it into request folder and rename each copied file in request folder by adding a "_V2" string.


Log activities:

-If result folder doesn't exist.
-If request folder doesn't exist.
-Files that have been removed.
-Files that have been copied from result folder to request folder.
-If a reported files name hasn't been copied.

If you have questions, please contact me.

Thank you very much for your help.
SOLUTION
Avatar of Bill Prew
Bill Prew

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 Luis Diaz

ASKER

Thank you very much Bill for this solution.

I will test it as soon as I can.

Concerning your question the various files are automatically transferred every 3 minutes from Request folder to Result by another application this is why we will find it in Result folder.
Hello Bill,

I am sorry for the delay.

I tested your proposal but I have some issues:

1-The delete is not performed in files which contain "_V2" in Result Folder:

Example
Original Result Folder:

User generated image
When I launch the script I have the following result in Result Folder:

User generated image
As you can see the "_V2" file hasn't be removed removed but it correspondent has been removed. However the script should perform the opposite action remove the "_V2" and keep the original correspondent file.

Concerning the copy / move action.

I reported in my listing.file the following files:
User generated image
However when I launch the script I just have one csv file in Request Folder:

User generated image
Based on the initial Result Folder I should get two files and not just one file.
User generated image
I supposed that I need to put a separator between the two files however I don't which should I use.
Could you please let me know how should I report the listing file?

Thank you very much for your help.
ASKER CERTIFIED SOLUTION
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
Thank you very much for your feedback.

My mistake, I re-test the script and it works perfectly.

I added

objFSO.CopyFile strOldPath, strNewPath
Avatar of Bill Prew
Bill Prew

Welcome.

~bp