Help answer threads with 0 replies.
Go Back > Forums > Linux Forums > Linux - Software
User Name
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.


  Search this Thread
Old 06-18-2008, 12:17 PM   #1
LQ Newbie
Registered: Oct 2002
Distribution: Slackware, Fedora
Posts: 8

Rep: Reputation: 0
Finding and moving files with find

Hi, this is probably a really basic question, but between the manpage and my Nutshell book and some other sources I'm still not figuring out what I'm doing wrong.

The problem, I unzip some mp3 archives which decompress into a series of sub-directories. I want to move into each sub-directory, pluck out the individual .mp3 files and move them to another directory altogether. What I'm doing looks like this:

noexit@uranus:~/files/Tripping Daisy$ find . -iname '*.mp3' -execdir mv ~/Music/Tripping_Daisy '{}'\; +

Which I think is saying "go into each sub-directory, look for any file with .mp3 in the name, and move it to ~/Music/Tripping_Daisy, then repeat".

What happens though is this:
noexit@uranus:~/files/Tripping Daisy$ find . -iname '*.mp3' -execdir mv ~/Music/Tripping_Daisy '{}'\; +
mv: target `./01 - Field Day Jitters.mp3' is not a directory
mv: target `./05 - Sigmund & The Sea Monsters Theme.mp3' is not a directory
mv: target `./10 - Triangle.mp3' is not a directory
mv: target `./11 - Halo Comb.mp3' is not a directory
mv: target `./11 - Prick.mp3' is not a directory

The directories:
noexit@uranus:~/files/Tripping Daisy$ ls
(1993) - Bill
(1998) - Jesus Hits Like The Atom Bomb
Rares, B-sides
(1995) - I Am An Elastic Firecracker
(1999) - Tripping Daisy

If I just do
find . -iname '*.mp3'
Then it finds and lists each file in each sub-directory, as expected.

I'm using Kubuntu Hardy.

I've tried various combinations and still can't make this work. I've done it in the past so I know I'm missing something, and I don't think it should be terribly complicated. What am I doing wrong or missing?

Thanks for any help,

Old 06-18-2008, 12:30 PM   #2
Senior Member
Registered: Mar 2004
Location: Cary, NC, USA
Distribution: Fedora, Kubuntu, RedHat, CentOS, SuSe
Posts: 1,288

Rep: Reputation: 99
You want to move all the mp3's into a single directory?

mkdir newdir
find . -iname \*.mp3 -exec mv {} newdir \;

Old 06-18-2008, 12:34 PM   #3
LQ Newbie
Registered: Oct 2002
Distribution: Slackware, Fedora
Posts: 8

Original Poster
Rep: Reputation: 0
Solved my own problem. The path has to go after the '{}', just like on the actual command line. Duh.
Old 06-18-2008, 12:35 PM   #4
LQ Newbie
Registered: Oct 2002
Distribution: Slackware, Fedora
Posts: 8

Original Poster
Rep: Reputation: 0
Thanks Forrest. I was re-reading my own post when I realized the stupid mistake I was making. Thanks for your response and verification.


commandline, kubuntu

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Finding files and then finding content within those files... Maeltor Linux - Software 5 03-13-2007 12:06 PM
find command : finding files that are created within last 24 hours Fond_of_Opensource Linux - Newbie 1 11-06-2006 03:47 AM
mySQL can't find files after moving to new server dbc001 Linux - Server 1 09-25-2006 12:19 AM
find -name and moving to file mijohnst Linux - General 5 08-26-2005 04:59 PM
having trouble with ls and find finding files. dr_zayus69 Linux - Software 4 05-26-2005 10:36 AM

All times are GMT -5. The time now is 06:26 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration