[Bash] sorts all your music in a sane file-structure via media-tags

jayvii 1f4c0921bb Moved to Script-group 8 months ago
README.md 1f4c0921bb Moved to Script-group 8 months ago
infochecker.run 1f4c0921bb Moved to Script-group 8 months ago
musicsorter.run 1f4c0921bb Moved to Script-group 8 months ago

README.md

Music-sorter

simple BASH-script for sorting all of your music via TAGS.

ATTENTION: Please read about the security concerns of using random scripts from the internet

1. Requires

mediainfo bash / zsh works best with a fully tagged music-files (Artist, Album, Title, Tracknumber, Year)

2. Tested with

VoidLinux mediainfo 0.7.76 bash 4.3.039 zsh 5.1

3. Variables

  • MANY_TRACK This variable holds the number of the "non-folder" files in your current directory (supposedly the number of all music-files in there). This number will tick down after each run.
  • ALREADY_EXIST This variable holds the number of all detected music-files, that already have a matching copy in your library.
  • CURRENT_TRACK This variable holds the name of the current file, the script works with. This variable will be reassigned after each run.
  • TITLE This variable holds the trackname of the current file and will be reassigned for each file.
  • ARTIST This variable holds the album-artist of the current file and will be reassigned for each file.
  • TRACKARTIST This variable holds the title-artist of the current file and serves as backup, in case "ARTIST" is not set.
  • ALBUM This variable holds the albumname of the current file and will be reassigned for each file.
  • YEAR (disabled) This variable holds the release-year of the current file and will be reassigned for each file.
  • TRACKNUM This variable holds the tracknumber of the current file and will be reassigned for each file.
  • FILESUFFIX This variable holds the extension of the current file (eg: "mp3", "ogg", "flac", ...). It will be reassigned for each file.
  • FILENAME (disabled) This variable holds the name of the current file without extension. It will be reassigned for each file.

4. How to

  1. make sure the example is executable (chmod)
  2. run the script from here with BASH/ZSH. (See the Example for further information)

5. Example

Syntax: $SHELL "/PATH/TO/musicsorter.run" "/PATH/TO/SOURCEFOLDER" "/PATH/TO/TARGEDFOLDER"

chmod +x "~/bin/musicsorter.run" # Only needed, if running for the first time
zsh "~/bin/musicsorter.run ~/unsorted_music ~/Music"

6. Further notes

  • Poorly tagged musicfiles will be moved into "unknown" folders.
  • The music-dir shall ONLY contain folders and music-files. All other files (eg: .jpg's) will be moved into "unknown".
  • The parameters included with the command SHOULD NOT end with a "/", indicating it being a folder. THIS IS VERY IMPORTANT! (See the Example for further information).

7. To-Do