cmd - Batch copy multiple files from different folders with their paths listed in a txt file, and rename any duplicates -
i've been trying tackle problem few days no avail. have no programming experience whatsoever , task has been driving me nuts.
i have txt file has list of paths files need copied. 8000 paths in file.
copying each item isn't such big deal can add copy command , destination before/after each path.
the crux of issue many of these files have same filename , when they're in different directories it's not problem.
however need files in same destination folder , keeps overwriting itself.
to sum up, have .txt file looks this:
d:\big folder\folder\subfolder a\filea.file d:\big folder\folder3\subfolder za\filek.file d:\big folder\folder\subfolder ds\filed.file d:\big folder8\folder\subfolder p\filea.file...
i need tool let me copy of these files 1 destination folder, , make sure duplicates renamed aren't overwritten.
such filea.file , filea.file become filea.file , filea1.file
edit: far i've come with
for /f "tokens=* usebackq" %i in (`type "c:\users\username\desktop\completelist.txt"`) copy "%i" "e:\destination\"
which read , copy job not rename part
save script below copy.bat, open cmd prompt script directory, , run bat. works me. post exact errors, if any.
@echo off setlocal enabledelayedexpansion set file=%userprofile%\desktop\completelist.txt set "dest=e:\destination" & set "i=" & pushd !dest! /f "usebackq tokens=*" %%g in ("%file%") ( call :rename %%~ng %%~xg %%g copy "%%g" "%dest%\!target!" >nul ) popd exit /b :rename set "target=%1!i!%2" :loop set /a i+=1 if exist "!target!" set "target=%1!i!%2" & goto :loop set "i=" & echo copied %3 !target! exit /b
Comments
Post a Comment