mardi 13 janvier 2015

If folder exists based on string, copy files to existing folder

I have a series of folders that I individually download via FTP on a daily basis.


Folder names are formatted as follows:



[DATE] [ID NO] [ID NAME]


Example:



W:\20150101 G0101 Building 1
W:\20150101 G0102 Building 2
W:\20150101 G0103 Building 3


[ID NO] and [ID NAME] are always the same. [DATE] changes each day.


I am trying to write a batch file to copy the contents of each FTP folder on a daily basis containing a known string to an equivalent local folder. Once the contents of each FTP folder are copied, the FTP folders are removed.


For example:



  • Always copy the folder containing the string "G0101" on FTP drive "W:\" to "C:\Building 1"

  • Always copy the folder containing the string "G0102" on FTP drive "W:\" to "C:\Building 2"


I have been playing around with IF EXIST but I can’t quite get the syntax right. Any assistance would be most appreciated!



IF EXIST "C:\00\*G0101*" XCOPY "C:\00\*G0101*\*.*" "C:\00\Building 1"


Regards


Martin :-)


Aucun commentaire:

Enregistrer un commentaire