i am currently making a script that searches all .mp3 files by idTags. I am using id3tools. Main problem with my code is that it will only work when the file path will only contain 5 of "/". I have to make it work 100% of the time, no matter what the file path is. My code:
#!/bin/bash
find /home -name \*.mp3 > songs.txt
while read line ; do
echo "$line" > new.txt
filePath=`cut -d "/" -f 1,2,3,4 new.txt`
name=` cut -d "/" -f 5 new.txt`
cd "$filePath"
id3tool "$name" > tmp.txt
if grep -q "2020" tmp.txt
then
echo $name
fi
cd
done < songs.txt
for example file path that will work: /home/bednar/Pobrane/fileName.mp3 and on the screen will ocure fileName.mp3