Last active
August 29, 2015 14:05
-
-
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.
This file contains 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 | |
# 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