0

So what I have at the moment is youtube-dl downloading into this folder "/media/zachary/Ante'esemone/Not in iTunes/" and it creates a folder with the name of the channel, for example:

  • Aliasizm
  • Caravan Palace
  • MrSuicideSheep

Then inside those folders are the .mp3 files labeled as:

  • Aether - Catharsis.mp3
  • Echos - Leave Your Lover.mp3
  • Hazey Eyes - Untitled.mp3

So I have a script that will edit the ID3 tags of all the files in 1 folder at a time, this script adds the name of the channel that it was downloaded from and adds the artist name from the file name to the ID3 tag as well. eg:

Aether - Catharsis.mp3

Becomes:

Catharsis.mp3 (With ID3 tags of "Aether" as the Artist and "Mrsuicidesheep" as the Comment)

But my current script (I'll add it below) can only do 1 folder at a time, what I need is a command (or an edit to the script) that can do all folders in the parent folder at once.

#!/bin/bash
for f in *.mp3; do
artist="$(printf "$f" | cut -d '-' -f 1 | sed 's/ *$//')"
eyeD3 --artist "$artist" "$f" 
mv -nv "$f" "$(printf "$f" | cut -d'-' -f 2 | sed 's/^ *//')"
done

^Will Add the Artist tag and rename the file to just be the Track name

I apologize for any initial confusion.

Zachary Wight
  • 55
  • 1
  • 11
  • Why don't use [lltag](http://home.gna.org/lltag/)? – Ipor Sircer Jan 12 '17 at 01:45
  • It might help to explain exactly what you're trying to do. The command that runs your script makes no sense at all really... – l'L'l Jan 12 '17 at 01:45
  • @l'L'l Basically I have youtube-dl download from a batch file into a directory and it downloads them into a folder that is named after the channel its from such as "/Caravan Palace/Caravan Palace - Lone Digger.mp3" and what my script that I'm trying to run does is take the part of the file name before the "-" and set the ID3 tag as the artist, and then cuts that from the file name. But I've made youtube-dl put them all in separate folders because I like to add an ID3 comment to the file as well that states which channel it came from. – Zachary Wight Jan 12 '17 at 02:05
  • @l'L'l If theres a way that I'm able to just add the ID3 tag to the comment section of them whilst they're in the folders then I can just put all the songs from all the channels into one folder and run my script from there, as that would work, I just need them to all be in their respective channel folders when they're labeled with the comment, that's all. – Zachary Wight Jan 12 '17 at 02:07
  • You should post that as part of your question; it makes much more sense now that you've explained it a bit. I still don't understand though what you are try to do with the command that runs the script. Are you just looking to have it scan through directories recursively and when it finds `mp3` files to run the script? Also if you could include an example of one the filenames that would help. – l'L'l Jan 12 '17 at 02:08
  • 1
    `youtube-dl` can tag the downloaded files with `--add-metadata` parameter, and the output name can be customized via OUTPUT TEMPLATES. It would be much easier to download the files directly in format what you like. – Ipor Sircer Jan 12 '17 at 02:11
  • 1
    @IporSircer: I agree on that; youtube-dl has some powerful options, it just takes a few minutes to scan through what it's capabilities are... zachary: the documentation is here: https://github.com/rg3/youtube-dl/blob/master/README.md#output-template – l'L'l Jan 12 '17 at 02:12

1 Answers1

0

Try this?:

#!/bin/bash
for f in */*.mp3; do
    directory=${f//\/*/}
    artist=$(printf "$f" | sed -e 's:[^/]*/::g' -e 's: - .*::g')
    eyeD3 --artist "$artist" "$f"
    mv -nv "$f" "$directory/${f//* - /}"
done

I removed the printf | cut | sed where I didn't think they were necessary, but feel free to do it that way.

Daniel Marks
  • 96
  • 1
  • 6