Created
August 15, 2018 10:10
-
-
Save matteobucci/0f57ca7f665f4e68b360da1a1193251b to your computer and use it in GitHub Desktop.
A simple bash script that helps copy multiple Android resources folder in a single one
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 | |
#This script is free software: you can redistribute it and/or modify | |
#it under the terms of the GNU General Public License as published by | |
#the Free Software Foundation, either version 3 of the License, or | |
#(at your option) any later version. | |
#This script is distributed in the hope that it will be useful, | |
#but WITHOUT ANY WARRANTY; without even the implied warranty of | |
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
#GNU General Public License for more details. | |
#You should have received a copy of the GNU General Public License | |
#along with this script. If not, see <https://www.gnu.org/licenses/>. | |
#Created by Matteo Bucci on 15/08/2018 | |
#I created this script for the simple reason that is very annoying to me extracting and moving the resources | |
#to my project directory when i work with Android | |
#So, this script simply extract all the files from its current directory and merge them in the destination directory | |
#TODO and nice to have for the future: | |
#-Support for the sorce directory | |
#-Option to decide whether to override or not the resources | |
#-Renaming options? Like adding ic_ at the beginning? Maybe | |
if [ $# -eq 0 ] | |
then | |
echo "Usage: $0 dirname" | |
exit 1 | |
fi | |
if [ ! -d "$1" ]; then | |
echo "$1 needs to be a valid directory" | |
exit 1 | |
fi | |
read -p "Are you sure to trasnfer all resources to $1? Press y or Y" -n 1 -r | |
echo # (optional) move to a new line | |
if [[ $REPLY =~ ^[Yy]$ ]] | |
then | |
for zip in *.zip | |
do | |
dirname=`echo $zip | sed 's/\.zip$//'` | |
if mkdir "$dirname" | |
then | |
if cd "$dirname" | |
then | |
unzip ../"$zip" | |
cd .. | |
# rm -f $zip # Uncomment to delete the original zip file | |
else | |
echo "Could not unpack $zip - cd failed" | |
fi | |
else | |
echo "Could not unpack $zip - mkdir failed" | |
fi | |
done | |
for D in */; do | |
rm -R ./$D/__MACOSX | |
rsync -av ./$D $1 | |
rm -R ./$D | |
done | |
exit 0 | |
else | |
echo "No problem :)" | |
exit 1 | |
fi | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment