Sample Header Ad - 728x90

Recursive thumbnail creation to different destination

1 vote
1 answer
260 views
I wish to show my photo collection on my television. In order to do this, I need to resize the photos to fit in a 1920x1080px window (because the performance is awful when dealing with the originals). My intended structure is:
/path/to/originalphotos/
/path/to/originalphotos/2016/2016-01-01 Description/DSC_1234.JPG
/path/to/originalphotos/2019/2019-12-31 Description/DSC_5678.JPG

/path/to/thumbnails/
/path/to/thumbnails/2016/2016-01-01 Description/DSC_1234_thumb.JPG
/path/to/thumbnails/2019/2019-12-31 Description/DSC_5678_thumb.JPG
I am trying to create a script that loops through /path/to/originalphotos/ and creates a thumbnail (using Imagemagick's convert utility) of every .JPG-file in the corresponding subdirectory. So far, my Bash script looks like this:
#!/bin/bash
SOURCE_PATH="/path/to/originalphotos/"
DESTINATION_PATH="/path/to/thumbnails/"
find "$SOURCE_PATH" -type f -iname '*.jpg' -exec sh -c 'echo convert \"$1\" -auto-orient -resize 1920x1080\> --write \"$DESTINATION_PATH${0%}_thumb.JPG\"' -- {} \;
*Note that I added echo to avoid saving any data.* Can you provide any help to store the thumbnails correctly? I have a gut feeling that I will encounter issues later on as some of my folder names contain special Danish characters (Æ, Ø, Å).
Asked by Kristian (699 rep)
Jan 25, 2020, 10:01 AM
Last activity: Jan 25, 2020, 11:25 AM