Sunday, May 5, 2024
8
rated 0 times [  8] [ 0]  / answers: 1 / hits: 12101  / 1 Year ago, tue, january 10, 2023, 10:42:30

Recently, I converted my music files to a different format. I have for example a folder of an artist containing the different albums in separate folders. I would knowing if is there a way to delete *.mp3 files in all my album folders of an artist using a simple command? For example, if I use ~music/artist_a/album1$rm *.mp3 it delete all the mp3 files of only the folder album1, but I want to use a command that delete all the mp3's of album1, album2,... in the artist_a folder.



Thanks!


More From » command-line

 Answers
6

If you go one level up, you can do:



~music/artist_a/album1$ cd ..
~music/artist_a$ rm */*.mp3


to delete mp3s from every directory inside the current. If you want to delete only from specific subdirectories:



~music/artist_a$ rm {album1,album2,album4}/*.mp3


You can also use find to delete all mp3 in subfolders of every level



~music/artist_a$ find . -iname '*.mp3' -delete


Use these command with caution.


[#41668] Thursday, January 12, 2023, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
ionash

Total Points: 214
Total Questions: 111
Total Answers: 116

Location: Sudan
Member since Thu, May 7, 2020
4 Years ago
;