You are not logged in.

#1 2023-05-03 13:39:27

furycd001
Member
Registered: 2021-07-14
Posts: 77

[SOLVED] Piping a file into cp or rsync....

HI..

I have a folder that contains thousands of video files and a playlist.m3u. The playlist only contains around a thousand or so files from the folder. Is it at all possible that I can pipe the playlist.m3u or if need be playlist.txt into cp or rsync and have everything listed copied over to another directory? There is that many files scattered within the folder that finding and copying them all manually would take literally forever. I'm not sure what I'm looking for is even possible because I've already googled and come up with nothing. Would kindly appreciate some help..


Many thanks in advance for reading & or replying....

Last edited by furycd001 (2023-05-03 15:22:24)


- - - -

Offline

#2 2023-05-03 14:00:30

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,744
Website

Re: [SOLVED] Piping a file into cp or rsync....

What's the format of the playlist?  If it's one full file/pathname per line the following should work:

while read fname; do cp $fname /path/to/dest-dir/; done < playlist.m3u

"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#3 2023-05-03 14:40:24

furycd001
Member
Registered: 2021-07-14
Posts: 77

Re: [SOLVED] Piping a file into cp or rsync....

The playlist is just a list of all the filenames ending with the extension.

#7195235677053734150 [7195235677053734150].mp4
10000000_734851161296093_4001355791333356526_n.mp4
10000000_182480604427118_3042941757594096833_n.mp4
48925863_5964554783625240_4542456356664720638_n.mp4
10000000_162706183212790_4164748308527594455_n.mp4
#7194134939221183750 [7194134939221183750].mp4
630610505126965096_2_20210801205213196.mp4
video 978465312258852.mp4
video 1591569486131564 nil 415646.mp4

The command you provided works, but it fails to copy any files that have spaces in their name....

Last edited by furycd001 (2023-05-03 14:44:37)


- - - -

Offline

#4 2023-05-03 14:51:20

seth
Member
Registered: 2012-09-03
Posts: 53,341

Re: [SOLVED] Piping a file into cp or rsync....

… cp "$fname" …

Online

#5 2023-05-03 15:17:13

furycd001
Member
Registered: 2021-07-14
Posts: 77

Re: [SOLVED] Piping a file into cp or rsync....

seth wrote:

… cp "$fname" …

A quick google came up with this command..

 for f in *\ *; do mv "$f" "${f// /_}"; done 

It replaces all the spaces with underscores & now everything works as expected....

Adding the quotes also worked. Going to mark this as solved. Thank you so much for the help guys....

Last edited by furycd001 (2023-05-03 15:22:15)


- - - -

Offline

Board footer

Powered by FluxBB