Skip to content

Instantly share code, notes, and snippets.

@fionera
Last active November 2, 2017 08:14
Show Gist options
  • Save fionera/948689bede26f2d26108b5f3991018a7 to your computer and use it in GitHub Desktop.
Save fionera/948689bede26f2d26108b5f3991018a7 to your computer and use it in GitHub Desktop.
Move Images from Shopware4 to the Shopware5 Structure
#!bin/sh
OLDFOLDER=/var/www/old/media/image
NEWFOLDER=/var/www/new/media/image
FILES=$(find $OLDFOLDER -maxdepth 1 -type f | sed 's!.*/!!')
for FILE in $FILES; do
MD5=$(echo -n $OLDFOLDER/$FILE | md5sum | awk '{ print $1 }');
FOLDER1=$(echo -n $MD5 | cut -c1,2);
FOLDER2=$(echo -n $MD5 | cut -c3,4);
FOLDER3=$(echo -n $MD5 | cut -c5,6);
if [ $FOLDER1 == "ad" ]; then
FOLDER1="g0"
fi
if [ $FOLDER2 == "ad" ]; then
FOLDER2="g0"
fi
if [ $FOLDER3 == "ad" ]; then
FOLDER3="g0"
fi
mkdir -p $NEWFOLDER/$FOLDER1/$FOLDER2/$FOLDER3;
mv $FILE $NEWFOLDER/$FOLDER1/$FOLDER2/$FOLDER3/$FILE;
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment