I have a list of files extracted from a table in a SQL database. The file can be either a delimited text file or an excel spreadsheet, whichever works best.
The file looks like this
sourcePath1\fileName1, destPath1\fileName1
sourcePath2\fileName2, destPath2\fileName2
sourcePath3\fileName3, destPath3\fileName3
etc
One column contains the original path and filename of the files, the second column contains the desired path and filename of the files. This has been obtained using a standard REPLACE() function in the original SELECT statement.
Now I have the list(s) I actually need to copy the source file to the destination.
Is this achievable using the command line (batch or Powershell?) or via scripting or a GUI?
Answer
Based upon David Ruhmann's answer, the following works. It uses xcopy
and passes an F
to the prompt that asks if the file is a file or folder.
@echo off
for /f "tokens=1,2 delims=," %%A in (book1.csv) do (
cmd /c echo F | xcopy "%%~A" "%%~B"
)
EDIT: Added tilde (~) as per @DavidRuhmann suggestion.
No comments:
Post a Comment