'Add a string to a copy command in a batch file
I want to give a previously declared string that represents a path I want in a copy command.
Something like:
SET PATH_SOURCE = "C:\lala.txt"
copy PATH_SOURCE "C:\folder\lala.txt"
Any idea?
Solution 1:[1]
This should work:
set "PATH_SOURCE=C:\lala.txt"
copy "%PATH_SOURCE%" "C:\folder\lala.txt"
Note that there must not be any spaces before or after the =. The % before and after the variable name make CMD expand the variable to the value you assigned before. The double quotes are a safeguard in case the path contains spaces.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Ansgar Wiechers |
