Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@thebaer
Last active August 29, 2015 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thebaer/3b365e572bde226a20b3 to your computer and use it in GitHub Desktop.
Save thebaer/3b365e572bde226a20b3 to your computer and use it in GitHub Desktop.
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