0

I have a little question. I've saved in a text file all the folders with sub-folders and files library of my music hard-drive and I try to clean this with notepad++.

I've removed the path of the hard-drive but now I want to keep only Artist/Album and remove songs titles.

For example, I have some filenames with paths:

/Mephista/Black Narcissus/01 The Children's House.mp3
/Mephista/Black Narcissus/02 Black Narcissus.mp3
/Mephista/Black Narcissus/03 Willow's Weep.mp3
/Mephista/Black Narcissus/04 Cabbalussa.mp3
/Mephista/Black Narcissus/05 Poison Ivy.mp3
/Mephista/Black Narcissus/06 Black Widow.mp3
/Mephista/Black Narcissus/07 Legend of Pele.mp3
/Mephista/Black Narcissus/08 Leda and the Swan.mp3
/Mephista/Black Narcissus/09 Laughing Medusa.mp3

(with sometimes the extension being .jpeg, as well), and I want to end up with this on each album (they are one after another):

Mephista/Black Narcissus

And then put them in alphabetical order.

I've started to do it by hand but I have 18000 lines so it will be very long if I can't find a way to automate this task (I tried some stuff but nothing works).

  • (Thanks for the "cleaning" Charlie"!) – Saynomore Nov 19 '14 at 15:20
1

Ctrl + H (Replace), in search mode select Regular expression

Find: ((/)([^//]+))$

Replace: {nothing}

Do it only once, of course

  • Well, the thing is that I have a LOT of different albums and artists so I doubt that I can do this like that... Don't you think? – Saynomore Nov 19 '14 at 15:21
  • Of course you can do it for all albums, if they are in format as your example. To get final alphabetical list with unique albums, copy cleaned result of Replace to Excel, select all, Data and use Remove Duplicates. Last task is using Sort. – Dolmayan Nov 19 '14 at 15:31
  • This is simply perfect!! :) Thanks a lot for your help Dolmayan! – Saynomore Nov 19 '14 at 18:07
1

Notepad++ is a great text editor but this is more an automation thing. If I might recommend another tool called AWK it might take some time to get a script right but once right it is a matter of seconds to get your desired output over and over.

I'm not familiar with Mac so I don't know if it will run without any problems but this does it for a windows. Asuming dir.txt is your file containing the listing and dir.awk is your script.

The contents of the file dir.awk, your script.

{print $2 " - "  $3}

Then the way to run your script is: `awk -F "/" -f dir.awk dir.txt > result.txt' which will output a result file looking;

Mephista - Black Narcissus 
Mephista - Black Narcissus 
Mephista - Black Narcissus 
Mephista - Black Narcissus   
Mephista - Black Narcissus
Mephista - Black Narcissus 
Mephista - Black Narcissus 
Mephista - Black Narcissus 
Mephista - Black Narcissus

That is a start, with uniq you can filter the result file for duplicates.

  • Yea... but I can find a way to do that... I just want, on my 10.4 mac, to have a list of all the hard-drive content, but just folders and subfolders. And I can't find a way. So I try some stuff like that. But AWK like automation seems a bit harsh, particularly when I just want to do it once and considering I need that soon... :/ – Saynomore Nov 19 '14 at 15:24
  • 1
    Oh... Darn it, I just see your details at the moment and I've already cleaned this up with Dolmayan technique... :/ Sorry! But thanks for the tip, I will try it anyway and keep this page in bookmarks for the future! ;) – Saynomore Nov 19 '14 at 18:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.