Skip to content

Instantly share code, notes, and snippets.

@masakiplus masakiplus/test.sh
Created Jun 28, 2015

Embed
What would you like to do?
#!/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
You can’t perform that action at this time.