I need to copy a few files and folders to their respective destinations using a Windows batch script.
All the files and folders I am supposed to copy, are kept within a folder, SOURCE
.
Example:
- folder:
C:\X\Y\Z\SOURCE\A
- file :
C:\X\Y\Z\SOURCE\A.txt
- file :
C:\X\Y\Z\SOURCE\B.txt
- folder:
C:\X\Y\Z\SOURCE\ZZZ
The destination paths of all the above are provided as text file contents, destination.txt
.
Content of destination.txt:
C:\FinalDestination\D\A\...
C:\FinalDestination\N\A.txt
C:\FinalDestination\C\B.txt
C:\FinalDestination\U\ZZZ\...
Where three dots at the end signifies a directory, otherwise it's a file.
What I need to do in the above scenario is:
- Copy folder
A
fromSOURCE
toC:\FinalDestination\D\
- Copy file
A.txt
fromSOURCE
toC:\FinalDestination\N\
- Copy file
B.txt
fromSOURCE
toC:\FinalDestination\C\
- Copy folder
ZZZ
fromSOURCE
toC:\FinalDestination\U\
I don't know how to do it as I am pretty new to Windows command line.
I know XCopy
is a command which can work for me, xcopy source destination
, but I don't know how to extract the source and destination details.