I've got a text file listing 1823 files that need to be copied from their current locations, i.e.
To another folder, any idea how I should do this?/media/blackhole/Audio/Music/whatever.mp3
/media/blackhole/Audio/Music/sowhat.mp3
Thanks.
I've got a text file listing 1823 files that need to be copied from their current locations, i.e.
To another folder, any idea how I should do this?/media/blackhole/Audio/Music/whatever.mp3
/media/blackhole/Audio/Music/sowhat.mp3
Thanks.
Code:while read file; do cp -vb "$file" /path/to/dir done < /path/to/file
Last edited by sisco311; June 14th, 2010 at 09:11 PM.
I've got an idea how you mean for this to be used, but I'm kind of confused.
I'm thinking drop that code in a text file as move.sh, change /path/to/dir to the intended destination for all those files, and /path/to/file to the path to the text file full of files? i.e. foobar.txt?
so it'd look like
and then run it from the terminal, how far off base am I?Code:#hope I got this right while read file; do cp -vb "$file" /home/jay/test done < /home/jay/foobar.txt
Thanks for the help!
Yep, you can create a scrip (move.sh) if you wish, but the code is very trivial an short you can type (copy/paste) it directly in the terminal. You can even write it in one line:
Of course, if you plan to run it multiple times, then create a script:Code:while read file; do cp -vb "$file" /home/jay/test; done < /home/jay/foobar.txt
Don't forget to make it executable:Code:#!/bin/bash while read file; do cp -vb "$file" /home/jay/test done < /home/jay/foobar.txt
Code:chmod +x ./move.sh
Thanks, you're a life saver! I just moved all but a few of the files that had weird filenames that cp choked on, but that's easy enough to fix.
Bookmarks