Hi all,
I have a FreeNAS server hosting all of my images. The original images are high resolution. What I would like to do is 2 parts:
- do a batch resize of all of the images so I have web-friendly version and print ready version
- run a cron job to apply the bash to any "new" files
First I want to tackle the bash script. As far as I can tell, these are the things that I must take into account:
- I have a directory structure that I want to duplicate and maintain
- I want to keep the originals
- I want a duplicate that is web-friendly
- Original dir is "./pictures"
- New dir is "./resized"
- Script will live in the "/pictures" dir
- Identify new images
I think that is it! :rolleyes:
I know how to copy the structure but I don't think that Imagemagick will check recursively by itself. That is where I am stuck.
I'm relatively new to bash, but here is what I have so far:
#!/bin/bash
# find all directories, copy structure
find . -type d | cpio -pvdm ../resized
# creates the new image, move to new dir
for f in *.jpg;
do
echo "Processing $f"
convert -resize "50%" \
$f ./resized/$f
done
The copy of the image "$f ./resized/$f" will just be dumped into the root of "/resized". So I am stuck there too.
I'm also wondering about the logic for the next step of checking for new images, then running the convert part on that. Is there a command that will compare the dir and identify the new files?
I appreciate any help!
Thanks!