Bulk resize images and keeping original files

Suppose you have a directory (with subdirectories) full of images, and you want to resize them all while keeping the original images. To do so, first create a copy of the directory tree without the image files. Then, using a for loop, find each image file and apply the convert command to it. The following is an example to resize jpg files to 40% of the original quality.

mkdir /path/to/mirror_dir
find /path/to/image_dir -type d -exec mkdir -p /path/to/mirror_dir/{} \;
cd /path/to/image_dir
for i in $(find -iname "*.jpg"); do echo $i; convert -resize 40% $i /path/to/mirror_dir/$i; done

(Batch) Amplify audio files from the command line

Audacity is great, but it’s a GUI and sometimes I just want to do basic things like amplify the sound of some mp3 files. Discovered mp3gain from this thread and wrote this script to batch amplify the files:

 <pre class="src src-sh"><span style="color: #ff4500;">#</span><span style="color: #ff4500;">! /bin/</span><span style="color: #00ffff;">bash</span>

## http://boards.straightdope.com/sdmb/archive/index.php/t-339352.html

gainval=10 for file in “$@” do mp3gain -g $gainval $file done

Note that mp3gain alters the original mp3 files directly. My default value is 10; feel free to alter it.

Bash batch script to convert org-mode file to html

I recently read this on reddit. I adapted the script on there to convert multiple org-mode files to html files. If you use it make sure you adapte the location of org-mode and your org.el file. Enjoy.

 <pre class="src src-sh"><span style="color: #ff4500;">#</span><span style="color: #ff4500;">! /bin/</span><span style="color: #00ffff;">bash</span>

## http://www.reddit.com/r/emacs/comments/dy9yt/anyone_know_of_a_script_that_i_can_feed_an/ ## http://www.ibm.com/developerworks/library/l-bash2.html ## http://desk.stinkpot.org:8080/tricks/index.php/2007/02/concatenate-strings-in-bash/ f=“” for file in “$@” do ##emacs –batch -q –no-site-file –eval “(add-to-list ‘load-path “~/.emacs.d/org-mode/lisp/”)” –load $HOME/.emacs.d/org-mode/lisp/org.el –visit ${file} –funcall org-export-as-html-batch f=“${f} –visit ${file} –funcall org-export-as-html-batch” done emacs –batch -q –no-site-file –eval “(add-to-list ‘load-path “~/.emacs.d/org-mode/lisp/“)” –load $HOME/.emacs.d/org-mode/lisp/org.el $f ## use emacsclient, check if running, execute. otherwise u this ## NO, emacsclient takes in elisp argument with –eval, not list list of files (will need to write my own elisp function…not worth effort)