Created
August 31, 2017 15:41
-
-
Save joahking/e3bd216d62a03eae39d8d178e0c9b8db to your computer and use it in GitHub Desktop.
Script used in ifeelmaps.com to rename converted images to original ones
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
#!/bin/bash | |
# Rename files file_imagemagick_converted.extension to file.extension | |
# | |
# Usage: | |
# grep -v imagemagick_converted bigger_imgs | ./rename-imgs.sh | |
# | |
# Arguments: | |
# stdin - list of filenames | |
suffix=imagemagick_converted # the suffix used to generate converted images | |
while read -r filename; # loop over filenames passed over stdin | |
do | |
dot_index=`expr index $filename .` # find the dot index in filename | |
name=${filename:0:dot_index-1} # characters before the dot | |
extension=${filename:dot_index} # characters after the dot | |
converted="$name"_"$suffix".$extension | |
if [ -e "$converted" ] # converted image exists? | |
then | |
`mv $converted $filename` | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment