You are not logged in.

#1 2020-01-18 08:45:38

jonno2002
Member
Registered: 2016-11-21
Posts: 129

[solved]how to copy a list of files to a folder ?

having a bit of trouble trying to copy a list of files with full paths into a single directory without preserving the paths.

for example the list is a file called 'list' containing the following:

/foo/bar/1.txt
/bar/2.txt
/bar/foo/3.txt
/foo/bar/foooo/baaar/4.txt

and i want to copy all the txt files into a single directory called 'directory' like this:

./directory/1.txt
./directory/2.txt
./directory/3.txt
./directory/4.txt

ive managed to copy all the files into the directory using this command:

rsync -v --files-from=list / ./directory

BUT they are copied with full paths which i dont want:

./directory/foo/bar/1.txt
./directory/bar/2.txt
./directory/bar/foo/3.txt
./directory/foo/bar/foooo/baaar/4.txt

i know its probably stupidly simple but ive searched and failed thus far.

the real 'list' contains ALOT of paths hence wanting to automate this mass copy.

any help would be appreciated

Last edited by jonno2002 (2020-01-18 11:58:06)

Offline

#2 2020-01-18 09:12:57

edacval
Member
From: .LT
Registered: 2008-10-23
Posts: 69

Re: [solved]how to copy a list of files to a folder ?

rsync -v --dry-run /first/file /second/file /more/files.... /target/dir

Offline

#3 2020-01-18 11:57:29

jonno2002
Member
Registered: 2016-11-21
Posts: 129

Re: [solved]how to copy a list of files to a folder ?

figured it out:

rsync -v --files-from=list --no-relative / ./directory

adding the --no-relative did the trick, feel like a moron, sorry for this waste of a thread, please close/bin/delete

Offline

Board footer

Powered by FluxBB