Assuming you have a list of the source directories in column A of your spreadsheet, then you could use an Excel formula such as the following in column B (or wherever you want to place it):
=CONCAT("robocopy ", """", A1, """", " ", """", "G", RIGHT(A1, LEN(A1) -1), """", " /s /e /copyall /xo")
Four double-quotes in a row result in one double-quote being generated as output.
The formula RIGHT(A1, LEN(A1) -1)
simply trims the leading E
(directory) from the path, so it can be replaced with the target G
.
If A1 contains E:\File\Example
then my formula generates the output:
robocopy "E:\File\Example" "G:\File\Example" /s /e /copyall /xo
Copy that formula down for as many rows as you need, then copy/paste the results to a text file (you may need to use paste-special to paste the resulting text, not the formula.
Rename the text file so it has a .bat
file extension, so it is runnable from a CMD prompt. I would test the batch file with a very small number of commands first of all.
This approach is fine, I would say, for a one-time (or few-times) exercise. If you were doing this many times, then yes an automated (Java, Python, etc.) approach may make more sense.
Update:
For your updated comment below, the relevant formula would be very similar to the one I provided above:
=CONCAT("robocopy ", """E:\apl_cad\", A1, """", " ", """\\ara1app2\ENG3\PROTEÍNAS\OldVersions\", A1, """", " /s /e /copyall /xo")
If A1
contains X
then the formula generates the following:
robocopy "E:\apl_cad\x" "\\ara1app2\ENG3\PROTEÍNAS\OldVersions\x" /s /e /copyall /xo
You can place that formula wherever you like - but make sure you adjust the cell references to A1
so they match wherever the actual X
data is located.