Skip to content

Instantly share code, notes, and snippets.

@ryaan-anthony
Last active December 25, 2015 19:09
Show Gist options
  • Select an option

  • Save ryaan-anthony/7026244 to your computer and use it in GitHub Desktop.

Select an option

Save ryaan-anthony/7026244 to your computer and use it in GitHub Desktop.
1. Put this script in your /shell/ directory (from within magento root).2. Running the script will move all images to their respective directories, will create directories that do not exists.example:original: /media/catalog/product/ABC.jpg gets moved to: /media/catalog/product/A/B/ABC.jpg
#!/bin/bash
cd ~/public_html/media/catalog/product
find . -maxdepth 1 -type f $1 | while read x; do
filename=$(basename "$x")
first=${filename:0:1};
second=${filename:1:1};
mkdir -p "$first/$second";
mv -f "$x" "$first/$second/$filename";
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment