How do i use RoboCopy where the destination is pinpointed with the name of a file?

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
fruitsalad23
Posts: 1
Joined: 05 May 2021 12:03

How do i use RoboCopy where the destination is pinpointed with the name of a file?

#1 Post by fruitsalad23 » 05 May 2021 12:06

So I want to build a script which copies data from my drive to my USB-Stick. However it should copy it to a specific USB-Stick. To do this I put a .txt file on the stick. If the stick has this specific .txt file it should copy it to that stick where the file is. However how do I set in Robocopy the source and destination?

FOR %%i IN (D E F G H I J K L M N O P Q R S T U V W X Y Z) DO IF EXIST %%i:\ usb_stick.txt SET USBST=%%i: robocopy.exe %USBST%\ "E:\Data\USB Stick" /MIR

Would really appreciate the help, thank you!

aGerman
Expert
Posts: 4140
Joined: 22 Jan 2010 18:01
Location: Germany

Re: How do i use RoboCopy where the destination is pinpointed with the name of a file?

#2 Post by aGerman » 05 May 2021 15:25

Code: Select all

FOR %%i IN (D E F G H I J K L M N O P Q R S T U V W X Y Z) DO IF EXIST "%%i:\usb_stick.txt" robocopy "%%i:\." "E:\Data\USB Stick" /MIR
Just my guess.

Steffen

Post Reply