i want to copy files but keep duplicates. Heres what i have so far
xcopy /-y C:\Users\David\Desktop\batch\1\* /e C:\Users\David\Desktop\batch\2
pause
however i am trying to keep the duplicates and merge them instead, i dont care about renaming if i have to i just want to keep the duplicates
xcopy help
Moderator: DosItHelp
Re: xcopy help
I don't understand, what you want to do.
If you use the command lines:
then the originals are in C:\Users\David\Desktop\batch\1, and
the duplicates are in C:\Users\David\Desktop\batch\2.
So keeping the duplicates is just the wished behavior of xcopy.
And what do you want to merge... and what merge operation do you want to use?
penpen
If you use the command lines:
Code: Select all
xcopy /-y C:\Users\David\Desktop\batch\1\* /e C:\Users\David\Desktop\batch\2
pause
then the originals are in C:\Users\David\Desktop\batch\1, and
the duplicates are in C:\Users\David\Desktop\batch\2.
So keeping the duplicates is just the wished behavior of xcopy.
And what do you want to merge... and what merge operation do you want to use?
penpen
Re: xcopy help
This should copy all files in the source tree to the tree you defined, adding -new to the end of each filename if it already exists.
It relies on the fact that folder 1 and folder 2 are in the same subdirectory.
It relies on the fact that folder 1 and folder 2 are in the same subdirectory.
Code: Select all
@echo off
set "source=C:\Users\David\Desktop\batch\1"
set "target=C:\Users\David\Desktop\batch\2"
for /f "delims=" %%a in ('xcopy /l /e /y "%source%\*.*" "%target%\" ^|find ":"') do (
if exist "%%~dpa..\2\%%~na%%~xa" (
if not exist "%%~dpa..\2\%%~na-new%%~xa" (copy "%%a" "%%~dpa..\2\%%~na-new%%~xa") else (echo "%%~dpa..\2\%%~na-new%%~xa" already exists&pause)
) else (
copy "%%a" "%%~dpa..\2\%%~na%%~xa"
)
)
pause
Re: xcopy help
foxidrive,
was wondering if there is a way the files could be renamed to their original on xcopy - capitalization.
source - FileA.txt
target - filea.txt
after xcopy , target becomes newFileA.txt.[added new - is using your existing script]. Same file name capitalization as in source and target which is FileA.txt
source - FileA.txt
target - newFileA.txt
Windows does not recognize capital or lower filename case if they are same .only the content inside are checked.
The only option i could think at the moment is to delete the file at destination and when the new files from source is copied the filename case would match.
was wondering if there is a way the files could be renamed to their original on xcopy - capitalization.
source - FileA.txt
target - filea.txt
after xcopy , target becomes newFileA.txt.[added new - is using your existing script]. Same file name capitalization as in source and target which is FileA.txt
source - FileA.txt
target - newFileA.txt
Windows does not recognize capital or lower filename case if they are same .only the content inside are checked.
The only option i could think at the moment is to delete the file at destination and when the new files from source is copied the filename case would match.
Re: xcopy help
The new files that are copied to the target will have the capitalisation from the source files.
Any existing files in the target will remain as they are.
How do you want to change that?
Do you want the existing files in the target to be renamed to match the source? This extra line below in blue should do that:
if exist "%%~dpa..\2\%%~na%%~xa" (
ren "%%~dpa..\2\%%~na%%~xa" "%%~na%%~xa"
Any existing files in the target will remain as they are.
How do you want to change that?
Do you want the existing files in the target to be renamed to match the source? This extra line below in blue should do that:
if exist "%%~dpa..\2\%%~na%%~xa" (
ren "%%~dpa..\2\%%~na%%~xa" "%%~na%%~xa"
Re: xcopy help
foxidrive,
thanks. it helps.
Need to learn more on modifiers usage. thanks again
thanks. it helps.
