You are here:
> Bash scripts
> Copy and Scale Images
> Bash scripts
> Copy and Scale Images
This is just a simple script that will copy files from one location to another and then scale them.
I use this script so that I can when I upload photos for the photo gallery, I am not uploading massive photos (most of the photos I have are taken from a 10MP digital camera and the file size is generally 1.5Mb). There is a fairly large folder of photos, I don't sync them because the file names never change and if one of the same name exists, I don't copy it again. Simple but effective.
Note you might need to install mogrify to use the script.
sudo apt-get install mogrify
Below is the code for the script - you will obviously need to change the source and target directories (and maybe the resize parameter to something other than 800)
#!/bin/bash
SOURCE_DIR='/home/rdy/Desktop/images/sorted/';
TARGET_DIR='/var/www/website/plugins/photoGallery/photoGalleryUploads/';
echo "Copying from '$SOURCE_DIR' to '$TARGET_DIR'";
sleep 1;
echo ;
echo ;
cp -Ruv $SOURCE_DIR* $TARGET_DIR;
find $TARGET_DIR -maxdepth 99 -iname *.mov -exec rm -v {} ;
find $TARGET_DIR -maxdepth 99 -iname *.jpg -exec mogrify -verbose -resize 800 {} ;