Search code examples
linuxshellmoversync

move (or copy) files from a list in Linux


So, I have a list of files in a text file. I believe it's about 100,000 files.

The files in said list are spread across many directories, have different sizes, filenames, extensions, ages, etc.

I am trying to find a way to move those files, and just those, to another drive.

Complicating factor: some of the files have the same name, but are not the same file. They can't just be moved into one folder with an overwriting or ignoring policy towards multiples.

Preferably, I would like them to retain their directory structure, but only have the files that I want inside the destination directory. (the destination drive isn't big enough to simply copy everything).

Below is an example of some lines in the file:

    media/dave/xdd/cruzer/F#(NTFS 1)/Raw Files/Portable Network Graphic file/3601-3900/FILE3776.PNG/Windows/winsxs/amd64_microsoft-windows-o..disc-style-memories_31bf3856ad364e35_6.1.7600.16385_none_51190840a935f980/Title_mainImage-mask.png

media/dave/xdd/d1/other/hd1/Program Files/DVD Maker/Shared/DvdStyles/Memories/Title_content-background.png

I have tried to use rsync -a --files-from=/sourcefile.txt / /media/destinationhdd

However, this just tries to copy my root directory to the destination. Please help, how to I just copy the accursed files that I want to?


Solution

  • cat list | xargs tar cf - | (cd dest; tar xvfp -)
    

    Where list is the file which contains all the file paths. dest is the target directory