Last active
March 3, 2021 08:12
-
-
Save th0rgall/9a7ac0667cc28652f076fa71c6ae6421 to your computer and use it in GitHub Desktop.
Download Shopify Admin Files given a comma-separated list text file
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/bash | |
# By @th0rgall - Feb. 1 2021 | |
# Tool that loops over Shopify File URLs and downloads them with CURL | |
# Prerequisites: | |
# - In you PATH: curl > v7.22, sed | |
# - A file with shopify file names: use Jason Bowman's script at https://gist.github.com/freakdesign/a1636414cce682c2c444#file-get-all-files-from-shopify-admin-js | |
# to download a file list (more details on this: https://freakdesign.com.au/blogs/news/113610119-export-a-list-of-all-files-in-the-shopify-admin) | |
# Usage: ./shopifyfiles shopify-files-list.txt | |
# The script will make a directory 'files' and download files there | |
# read file list into a variable | |
filelist=$(cat "$1") | |
# make dir files | |
mkdir -p files | |
cd files | |
# loop over filelist split by comma | |
for i in ${filelist//,/ } | |
do | |
# download file with CURL, using the file name (& header file name if applicable, but it's probably not applicable) | |
curl -O -J "$i" | |
done | |
# remove the URL parameter parts | |
find ./ -type f -d 1 -name '*.*?*' -exec bash -c 'mv "$0" "$(echo "$0" | sed -E "s/\?.*$//")"' {} \; | |
cd .. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment