I am writing a Bash script to clean up in my music.
I wanted him to format all the file names and make them, and so with a little search on the Internet I wrote this line:
sed -i -e 's/[-_]/ /g' -e 's/ \+/ /g' -e **'s/\<[az]/\U&/g'** -e "s/$artist //g" -e "s/$album //g"
What I used to add file names to a text file and then sed, but then I did not know how to apply the new names to the files.
So, I started experimenting with renaming and was able to get the same result except for the bold parts, which should make every first letter in a word in uppercase.
rename 's/[-_]/ /g' * && rename 's/\s+/ /g' * && **rename 's/\s\w{1}/*AZ*/g' *** && rename 's/^\d+[[:punct:]]\s//g' * && rename "s/$artist\s//g" * && rename "s/$album\s//g" * && rename "s/($ext)//g" *
Now the code in the rename works (at least satisfactorily), finding only one letter after the SPACE character, but this is a replacement problem. I tried many different approaches, and all this left me with the result that the first letter in focus in this case is exchanged exactly for AZ.
The rename man page on the page says that you do lowercase in uppercase, which you do / a -z / AZ / g, but itโs easy to understand that it only applies when it finds az AZ. So I need help.
The bonus would be if someone knows how to do this, as in the sed example, where \ <matches the beginning of each word, because at the moment my rename command will not apply to the first word and will not apply if for obvious reasons there are several discs similar to "Disc name [Disc 1]".
Jompa
source share