Unzipped Plugins - still possible?

Here’s version 2 of the script, which handles Finder Aliases and makes a backup of plugins in a “Plugins_Backup” folder. It’s also using a hard-coded pathname so you can save it as a .command file and just double-click it in the FInder to run.


#!/bin/bash

# UnzipXojoPluginsV2.command
# A script to uncompress plugin archives to have Xojo load them faster.
# see https://forum.xojo.com/57793-unzipped-plugins-still-possible/2019/1
# by Michael Diehr 
# Thanks to Jim Mckay and others for creating the original script.

# be sure to chmod +x this script file


# Changes from earlier versions:
# - Now properly handles Finder Aliases (the kind you get with command-option drag)
#   this is useful if you like to keep your Plugins elsewhere
#
# - Is non-destructive - plugins (real or alias) are always moved to 
#   the Plugins_Backup/ folder
#
# - can be double-clicked: if you save this as a .command file (and chmod +x it)
#   then you can simply double-click it in the finder to run it


# set the path to your Xojo app here:
ROOT="/Applications/Xojo/Plugins/"

cd "$ROOT"


# a backup folder where we move originals, so this script is non-destructive
backups="../Plugins_Backup"
mkdir -p "${backups}"

for f in *.xojo_plugin
do
  if [[ ! -d "${f}" ]]
  then
    echo "Processing ${f}"

	# if the xojo_plugin file is a Finder alias to a file elsewhere on disk
	# handle it differently
	fTruePath=`osascript <<EOD
	set toPath to ""
	tell application "Finder"
		set toPath to (POSIX file "$ROOT/${f}") as alias
		set theKind to kind of toPath
		if theKind is "Alias" then
			set toPath to ((original item of toPath) as alias)
			return posix path of (toPath)
		end if
	end tell
	return ""
	EOD`


	if [ "${fTruePath}" ] 
	then
		echo "ALIAS: ${fTruePath}"
		# for an alias, we have to move the original alias file to get it out of the way
		mv "${f}" "${backups}/${f}"
		mkdir "${f}"  # create the _xojo_plugin folder
		# unzip directly from the original file (not the alias) to here
		yes | unzip -d "${f}" "${fTruePath}"
	else
		# this is not an alias file, handle it right here
		echo "FILE: ${f}"
		mv "${f}" "${backups}/${f}"
		mkdir "${f}"  # create the _xojo_plugin folder
		# unzip directly from the file in the backup folder to here
		yes | unzip -d "${f}" "${backups}/${f}"
	fi

  fi
  
  echo ""
  
done