proj=12612306; mkdir sb2tmp; cd sb2tmp; curl -L http://projects.scratch.mit.edu/internalapi/project/$proj/get/ 2> /dev/null | tee project.json | grep -i MD5 | cut -d’ ’ -f2 | sed ’s/[\”,]//g’ | while read file; do curl -L -o $file http://scratch.mit.edu/internalapi/asset/$file/get 2> /dev/null; done; i=1; while [ $i -le `expr $( ls -1 | wc -l ) – 2` ]; do sed -i ”{s/ID\”: -1/ID\”: $i/;t end;b;:end;n;b end}” project.json; i=`expr $i + 1`; done; i=0; ( grep penLayerMD5 project.json; grep ’\(baseLayerMD5\|md5\)’ project.json ) | cut -d’ ’ -f2 | sed ’s/[”,]//g’ | while read file; do ext=`echo $file | cut -d. -f2`; mv $file $i.$ext; i=`expr $i + 1`; done; zip $proj.sb2 *; mv *.sb2 ..; cd ..; rm -r sb2tmp

Detta hämtar ett Scratch 2-projekt (sb2-fil) med det angivna numret. Notera att detta ej fungerar för Scratch 1.4-projekt, men för dem finns en enklare lösning, se annat inlägg.

Man kan också hämta ner alla projekten i en studio:

studio=263477; curl -L http://scratch.mit.edu/site-api/projects/in/$studio/1/ 2> /dev/null | sed -n ’/title.*projects\/[0-9]*/ {s/.*projects\/\([0-9]*\).*/\1/;p}’ | while read proj; do echo $proj; mkdir sb2tmp; cd sb2tmp; curl -L http://projects.scratch.mit.edu/internalapi/project/$proj/get/ 2> /dev/null | tee project.json | grep -i MD5 | cut -d’ ’ -f2 | sed ’s/[\”,]//g’ | while read file; do curl -L -o $file http://scratch.mit.edu/internalapi/asset/$file/get 2> /dev/null; done; i=1; while [ $i -le `expr $( ls -1 | wc -l ) – 2` ]; do sed -i ”{s/ID\”: -1/ID\”: $i/;t end;b;:end;n;b end}” project.json; i=`expr $i + 1`; done; i=0; ( grep penLayerMD5 project.json; grep ’\(baseLayerMD5\|md5\)’ project.json ) | cut -d’ ’ -f2 | sed ’s/[”,]//g’ | while read file; do ext=`echo $file | cut -d. -f2`; mv $file $i.$ext; i=`expr $i + 1`; done; zip $proj.sb2 * > /dev/null; mv *.sb2 ..; cd ..; rm -r sb2tmp; done