I am trying to create a video of some photos I numbered them thinking that when I imported them into Pitivi they would appear in numerical order. Not so. They sort alphabetically 1,10,11,100 instead of 1,2,3,4.
So to get the result I wanted I created a script to copy the images to a new location with a new alphabetically sortable name (AA, AB, AC... ZZ):
Step 1 - was to get a list of the images to rename
cd /path/to/images ls -1 | sort -n > filelist
Step 2 - Open filelist in and copy into LibreOffice calc and create a script containing the commands you need. There are a million ways to do this but I find using calc / excel is familiar and easy
#!/bin/bash mkdir renamed cp "1_RIMG0001.jpg" "renamed/AA-1_RIMG0001.jpg" cp "2_RIMG0002a.jpg" "renamed/AB-2_RIMG0002a.jpg" cp "3_RIMG0003.jpg" "renamed/AC-3_RIMG0003.jpg" cp "4_Picture_001.jpg" "renamed/AD-4_Picture_001.jpg" cp "5_Picture_024.jpg" "renamed/AE-5_Picture_024.jpg" cp "6_Picture_017.jpg" "renamed/AF-6_Picture_017.jpg" cp "7_Picture_035.jpg" "renamed/AG-7_Picture_035.jpg" cp "8a_RIMG0001.jpg" "renamed/AH-8a_RIMG0001.jpg" cp "8_Picture_061.jpg" "renamed/AI-8_Picture_061.jpg" cp "9_RIMG0004_001.jpg" "renamed/AJ-9_RIMG0004_001.jpg" cp "10_RIMG0007_001.jpg" "renamed/AK-10_RIMG0007_001.jpg" cp "11_RIMG0005_002.jpg" "renamed/AL-11_RIMG0005_002.jpg" cp "12_RIMG000_2.jpg" "renamed/AM-12_RIMG000_2.jpg" cp "13_RIMG0001_004.jpg" "renamed/AN-13_RIMG0001_004.jpg" cp "14_RIMG0045.jpg" "renamed/AO-14_RIMG0045.jpg" cp "15_RIMG0001_005.jpg" "renamed/AP-15_RIMG0001_005.jpg"
Once you have the commands created copy them from the spreadsheet into a text file in the same directory as your images and run it
gedit rename.sh # enter the commands into a textfile and save it chmod +x rename.sh # make it executeable ./rename.sh # run the script ls renamed/ | head -n 5 # check your results AA-1_RIMG0001.jpg AB-2_RIMG0002a.jpg AC-3_RIMG0003.jpg AD-4_Picture_001.jpg AE-5_Picture_024.jpg
0 Comments