Help answer threads with 0 replies.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 01-06-2011, 08:56 PM   #1
LQ Newbie
Registered: Jan 2011
Posts: 1

Rep: Reputation: 0
Requesting guidance for batch file deletion

I am running Ubuntu currently, although I have a feeling the solution to this will apply to many distributions, hence the post in "Newbie" ... but feel free to move if this belongs elsewhere!

I recently merged iTunes libraries, and after iTunes automagically moved and re-structured my music folder, there are now duplicate copies of many songs in the root directory of each artist folder.

I would like to delete all of the files within the first level of the directory structure of the iTunes Media directory. Any song files should be located one level deeper, within each album's folder.

Is there a simple way to accomplish this at the command line? I'm not sure what direction to begin looking, so any guidance is appreciated!
Old 01-06-2011, 10:48 PM   #2
David the H.
Bash Guru
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian + kde 4 / 5
Posts: 6,837

Rep: Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984
You can start by giving us an example of the file and directory tree(s) that we have to work with. Most likely it will just take find or a simple loop of some kind, but it all depends on exactly what paths and names are involved.
Old 01-06-2011, 10:55 PM   #3
LQ Guru
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 677Reputation: 677Reputation: 677Reputation: 677Reputation: 677Reputation: 677
Are there only Artist's folders in the base directory of your library?

If so, you could use:
find ./ -mindepth 2 -maxdepth 2 -type f -name "*.mp3" -delete


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
detect file deletion on an operating system and trace the file history or activity? lovsis Linux - Security 2 10-19-2010 08:52 AM
File Deletion mhkhalqani Linux - General 1 10-12-2005 03:08 AM
Automatic file deletion Azhrarn Linux - Newbie 5 08-30-2005 05:01 AM
Requesting kernel config file Kami.JZ Linux - General 6 05-25-2005 04:15 PM
Batch image dimension detection and deletion macskeeball Linux - Software 1 03-17-2005 03:54 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 06:57 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