Instantly share code, notes, and snippets.

@thebaer /renamer.sh
Last active Aug 29, 2015

Embed
What would you like to do?
Standardizes image file names (especially from iOS land) to be usable as Android resources.
#!/bin/bash
# Standardizes image file names to be usable as Android resources.
# Gotta have some parameters to continue
if [ -z "$1" ]; then
echo "usage: renamer.sh file [file2...]"
echo
exit 1
fi
for INFILE; do
# Do the stuff
if [ "$INFILE" != "${INFILE//-/_}" ]; then
# Replace hyphens with underscores
NEWFILE=${INFILE//-/_}
mv -i "$INFILE" "$NEWFILE"
else
NEWFILE=$INFILE
fi
if [ "$NEWFILE" != "${NEWFILE//@2x/}" ]; then
# Remove retina-ified filenames
mv -i "$NEWFILE" "${NEWFILE//@2x/}"
fi
echo "Moved $INFILE to ${NEWFILE//@2x/}"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment