Search code examples
cmdcommand-linexcopy

Copy files from a source folder that contains the same filenames as the destination folder


I have a folder of music files that I have added/updated ID3 tags (the source folder). I also have another folder containing some of these files (the destination folder), and I want to overwrite/update these by copying only files from the source folder that exists in the destination folder.

I tried using this xcopy command, which does the job it seems as it copies only files that exist in destination folder. But upon inspection, the relevant files in the destination folder are still the old ones which do not have ID3 tags. I cannot figure out why the copied files did not overwrite the old files:

cd /d "C:\Users\lenovo\Desktop\source"
for %x in (*) do xcopy "%x" "C:\Users\lenovo\Desktop\destination" /L /U /Y /I

Solution

  • xcopy /? says about the /L switch:

    /L           Displays files that would be copied.
    

    However, by https://ss64.com/nt/xcopy.html:

    
    /L    List only - Display files that would be copied.
    

    The latter is right!