Skip to content

Instantly share code, notes, and snippets.

@kumarasinghe
Created September 16, 2023 21:32
Show Gist options
  • Save kumarasinghe/7cfddc6844a9b1ccf867db8022a02e89 to your computer and use it in GitHub Desktop.
Save kumarasinghe/7cfddc6844a9b1ccf867db8022a02e89 to your computer and use it in GitHub Desktop.
Organize elementor template archives for previewing
# ORGANIZE ELEMENTOR TEMPLATE ARCHIVES FOR PREVIEWING
# RUN THIS BASH SCRIPT NEXT TO ZIP ARCHIVES
mkdir -p templates preview archives
i=100
# iterate archives
for archive in *.zip; do
archive_name=${archive%%.zip}
echo "processing $archive_name..."
# extract
extract_dir="templates/$i-$archive_name"
unzip "$archive" -d "$extract_dir" > /dev/null
# copy preview
thumbnail_path=`ls $extract_dir/screenshots/*home* 2> /dev/null | head -n 1`
if test -f "$thumbnail_path"; then
cp "$thumbnail_path" "preview/$i.jpg"
else
# if cannot find image create a placeholder
touch "preview/$i.jpg"
fi
# move archives
mv $archive "archives/$archive"
((++i))
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment