Skip to content

Instantly share code, notes, and snippets.

@typoman
Last active September 28, 2023 16:46
Show Gist options
  • Save typoman/2131c9702ba7f74d29eedd632528dc46 to your computer and use it in GitHub Desktop.
Save typoman/2131c9702ba7f74d29eedd632528dc46 to your computer and use it in GitHub Desktop.
Backup proxy of images and videos
#!/bin/bash
# Use this if you want to make a copy of your images and viodes with
# siginficant reduced size. This bash script duplicates the folder structure
# of all the sub folders underneath the current folder, and puts images and
# videos there. It also redcues the size of images and creates screenshots of
# videos instead of copying the resized video. Run it inside the folder that
# contains all your images, it will create another folder next to it and put
# the images and videos with reduced size there.
# - To make it executbale in terminal and same folder and run
# `chmod +x current_file_name.sh`
# - To excecue: ./current_file_name.sh
find * -type d -exec echo MKDIR {} \; -exec mkdir -p -- ../backup_images/{} \;
find -E * -iregex '.*\.(gif|jpg|jpeg|tiff|png)' -type f -exec echo RESIZE IMAGE {} \; -exec convert {} -resize 640X480 -quality 60 ../backup_images/{} \;
find -E * -iregex '.*\.(mkv|webm|flv|ogg|avi|mov|qt|wmv|mp4|m4v|mp|svi|3gp|flv|f4v)' -type f -exec echo VIDEO THUMBNAIL {} \; -exec ffmpeg -loglevel warning -ss 00:00:1 -i {} -vf select='not(mod(n\,400))',scale=300:-1,tile -frames:v 1 ../backup_images/{}.jpg \;
@typoman
Copy link
Author

typoman commented Oct 19, 2019

You need ffmpeg and imagemagick for this script to work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment