Last active
November 2, 2017 08:14
-
-
Save fionera/948689bede26f2d26108b5f3991018a7 to your computer and use it in GitHub Desktop.
Move Images from Shopware4 to the Shopware5 Structure
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/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