I frequently find myself renaming .flac-files in order to remove abundant information. I write a loop where I edit filenames by manually writing out the part that I want removed. E.g. I have a folder full of files like this:
$ ls -l
-rw-r--r-- 1 me me 315416376 Jan 6 2021 'Föllakzoid - 01 - I.flac'
-rw-r--r-- 1 me me 250380814 Jan 6 2021 'Föllakzoid - 02 - II.flac'
-rw-r--r-- 1 me me 336071410 Jan 6 2021 'Föllakzoid - 03 - III.flac'
-rw-r--r-- 1 me me 258787367 Jan 6 2021 'Föllakzoid - 04 - IIII.flac'
With the desired output being:
$ ls -l
-rw-r--r-- 1 me me 315416376 Jan 6 2021 '01 - I.flac'
-rw-r--r-- 1 me me 250380814 Jan 6 2021 '02 - II.flac'
-rw-r--r-- 1 me me 336071410 Jan 6 2021 '03 - III.flac'
-rw-r--r-- 1 me me 258787367 Jan 6 2021 '04 - IIII.flac'
Here I want to remove the "Föllakzoid - "-part from all of the files (as I that information is conveyed through a folder structure further up). Instead of manually typing
$ for file in *.flac; do a=`echo "$file" | sed 's/Föllakzoid - //'`; mv "$file" "$a"; done
I'd rather find the "Föllakzoid -"-part automatically and remove it from all files. Than I could abstract it into a script and re-use all the time (Thereby improving my bash-skills along the way).
I found some similar questions here (on stackoverflow) but they deal with lists of items where order is not important. In my case I want to search for equal substrings in multiple longer strings: I am looking for a function that returns the intersection of multiple strings. So the order of letters is important (as opposed to other questions about list-intersections.
Is there a simple tool in the riches of the depths of /usr/bin ?