What I am doing is converting mp3's with LAME. I already have an old script I wrote that works but I want to add to it this ability--to no longer delete the file but instead save it in a new root folder with sub-directories that match the using the path that it is already in.
This is the code I got off the Internet that I am using in my script to get the path:
c=$FILENAME
xpath=${c%/*}
xbase=${c##*/}
xfext=${xbase##*.}
xpref=${xbase%.*}
path=${xpath}
pref=${xpref}
ext=${xfext}
The xpath
and path
give me the directory structure /home/user/working-root-directory/band-folder/album-name/
Using that technique, how do I script this to get just the band-folder into a separate variable and the album-folder into a separate variable?
Then I can use them to create new folders keeping all the mp3s in band album order to put them into a different root folder; this would eliminate me from having to move them myself so the next time I run my script I will not re-sample them again because they will no longer be in the working directoy path/folders and still have a back up copy of my files just in case.