Created
March 12, 2013 19:35
-
-
Save mostlygeek/5146231 to your computer and use it in GitHub Desktop.
This gist is a collection of random things i've needed to do on the command line. Usually it is moving files around or scripting commands to run over a set of files.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# Source, a directory full of files like: t01-open.png, t02-open.png, etc. | |
# Output, rename the files so t01-open.png turns into t00-open.png (start at zero instead of 1) | |
# loop through all the numbers ... | |
for i in {1..20} | |
do | |
# turn 1, 2, 3, 4... into 01, 02, 03, 04 | |
f=$(echo $i | awk '{printf "%02s", $1}') | |
# turn 1, 2, 3, 4... into 00, 01, 02, 00 | |
# math is done w/ the expr command | |
v=$(expr $i - 1 | awk '{printf "%02s", $1}') | |
# move the old file name to the new file name... | |
mv t$f-close.png t$v-close.png | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment