0

I have a bash script that goes through my music folder, gets all the song metadata with mediainfo and is intended to make folders out of all the artists' names, but it fails.

This is the code so far:

#!/bin/bash cd Music/ for i in "$(ls -b | grep -v /)"; do info=$(mediainfo $i) artist=$(echo "$info" | grep "^Performer" | awk '{for(i=3;i<=NF;++i)printf $i""FS ; print ""}') mkdir "$artist" done 

For some reason, it seems to go through all the songs first and then tries to make a directory with all their names combined; my intent is to create a directory for the performer found by Mediainfo in each music file.

1 Answer 1

1

You can Iterate over files without ls.

for i in ./Music/*; do info=$(mediainfo "$i") # fixed to "$i" artist=$(echo "$info" | grep "^Performer" | awk '{for(i=3;i<=NF;++i)printf $i""FS ; print ""}') mkdir "$artist" done 

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.