Created
June 28, 2015 03:33
-
-
Save masakiplus/59b739749851766564ec to your computer and use it in GitHub Desktop.
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 | |
itemcount=0 | |
subcount=1 | |
for a in `ls G*.JPG 2> /dev/null` | |
do | |
echo "$a" | |
lastproduct="$productid" | |
productid=`echo "$a" | gawk '{print substr($a, 9,6)}'` | |
colorid=`echo "$a" | gawk '{print substr($a, 16,2)}'` | |
echo "last was "$lastproduct | |
echo "current is "$productid | |
echo "color is "$colorid | |
if [ "$lastproduct" != "$productid" ] | |
then | |
itemcount=0 | |
fi | |
mkdir $productid/main -p | |
mkdir $productid/color -p | |
if [ $itemcount -eq 0 ] | |
then | |
cp $a $productid/main/0.JPG | |
else | |
cp $a $productid/color/$colorid.JPG | |
fi | |
itemcount=`expr $itemcount + 1` | |
echo $itemcount | |
done | |
for b in `ls *sub*.jpg 2> /dev/null` | |
do | |
echo "$b" | |
lastproduct="$productid" | |
productid=`echo "$b" | gawk '{print substr($b, 1,6)}'` | |
echo "last was "$lastproduct | |
echo "current is "$productid | |
if [ "$lastproduct" != "$productid" ] | |
then | |
subcount=1 | |
fi | |
mkdir $productid/main -p | |
cp $b $productid/main/$subcount.JPG | |
subcount=`expr $subcount + 1` | |
echo $subcount | |
done | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment