Sorting photos
Written 2021-12-01 by Kalle
1 min read | 174 words
Background
Having imported images from my DSLR to a folder such as My_photo_session
, I end up with a directory containing raw and jpeg image files:
/My_photo_session
DSC_6494.JPG
DSC_6494.NEF
DSC_6466.JPG
DSC_6466.NEF
Before starting to develop the images in my raw image editing software of choice, I usually sort the images into two directories: one for raws and one for jpegs. Until now, this has been a manual process.
The script
The following script is saved as /usr/local/bin/sort_photos
:
#!/bin/bash
mkdir jpg
mkdir raw
mv *.JPG jpg
mv *.NEF raw
Result
Recall the file structure presented at the beginning of this post:
/My_photo_session
DSC_6494.JPG
DSC_6494.NEF
DSC_6466.JPG
DSC_6466.NEF
Executing the script from /developed_jpg
results in the following file structure:
/My_photo_session
/jpg
DSC_6494.JPG
DSC_6466.JPG
/raw
DSC_6494.NEF
DSC_6466.NEF
Reverting
If, for any reason, I execute sort_photos
but then change my mind, I can reverse the operation using the following script which is saved as /usr/local/bin/unsort_photos
:
#!/bin/bash
mv jpg/* .
mv raw/* .
rmdir jpg
rmdir raw