Skip to content

Instantly share code, notes, and snippets.

@speed-of-light
Created June 18, 2014 15:03
Show Gist options
  • Select an option

  • Save speed-of-light/078adb852c32f678446f to your computer and use it in GitHub Desktop.

Select an option

Save speed-of-light/078adb852c32f678446f to your computer and use it in GitHub Desktop.
decrease Increase file by 1 or other variable
#!/bin/bash
dir=$1
for f in "$dir"/*; do
pre=${f:0:4}
post=${f:7}
fn=$((${f:4:3} - 1))
jj=`printf "%03d" $fn`
mv $f $pre${jj}_tmp$post # prevent overrite
done
rename -v 's/(\w{3}\/\d{3})[_tmp]+.jpg$/$1.jpg/' $dir/*.jpg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment