Background
Rename one set of files based on a name that corresponds to another set, using a sort order based on file size to match the file names. The files from both sets have approximately the same sizes. Close enough that when sorted by file size both lists are in the same order. The number of files in each set is exactly the same.
Problem
First file set:
master~$ for f in $(ls -S); do echo $f; done
06-AudioTrack_06.flac
08-AudioTrack_08.flac
01-AudioTrack_01.flac
05-AudioTrack_05.flac
02-AudioTrack_02.flac
Second file set:
corrupt~$ for f in $(ls -S); do echo $f; done
Groove_de_V..flac
Jump.flac
Do_You_Savvy.flac
Gershwins_Blues.flac
Blue_Skies.flac
If_I_Had_A_Ribbon_Bow.flac
Question
How do you rename the first set as follows:
06-Groove_de_V..flac
08-Jump.flac
01-Do_You_Savvy.flac
05-Gershwins_Blues.flac
02-Blue_Skies.flac
Script
So far...
master~$ for f in $(ls -S); do
IDX=$(echo $f | awk '{print substr( $1, 1, 2 )}');
echo "mv $i $IDX-";
done
Produces:
mv 06-AudioTrack_06.flac 06-
mv 08-AudioTrack_08.flac 08-
mv 01-AudioTrack_01.flac 01-
mv 05-AudioTrack_05.flac 05-
mv 02-AudioTrack_02.flac 02-
Thank you!