On 05/31/2011 08:07 AM, Binand Sethumadhavan wrote:
2011/5/30 Rony <gnulinuxist(a)gmail.com>om>:
find
$HOME -name '*.mp3' -print0 | xargs -0 mv -t /music
and similarly for video etc.
I was just going to write that. I used
find . -name *.mp3 -exec mv '{}' Media/Music/ \ ;
There are three problems
with this.
1. If there is a something.mp3 in your current working directory, then
this will process precisely that file (and any other identically named
files). It will not process *all* mp3 files. In my original, I had
single-quoted *.mp3 for this reason.
I used different commands for mp3, MP3 etc. I guess all my songs have
been copied as many other folders are now empty.
2. Sometime in life, this find will descend into
Media/Music and
process the files there again - which are already moved. Wastage of
CPU cycles. Which is why I had used a /music that is outside of $HOME.
It happened when I ran the command again and it said "The file in
/path/file.mp3 is the same as /path/file.mp3". Anyway, now all my files
are in one place.
3. find | xargs is superior to find -exec, due to the
fact that the
former is more efficient. See:
http://blog.endpoint.com/2010/07/efficiency-of-find-exec-vs-find-xargs.html
Hmm. Thanks.
--
Freedom is a shared resource. Take some, leave the rest for others.
Please trim your replies. Avoid cross posting to other lists.
Post your replies below the relevant original text, leaving a line space.
Regards,
Rony.