Save the script to a directory in your PATH and name it appify (no extension). I chose to put it in /usr/local/bin, which requires root privileges.
Fire up Terminal.app and enter sudo chmod +x /usr/local/bin/appify to make appify executable without root privileges.
Adding a custom app icon
Create an .icns file or a 512×512 PNG image with the icon you want, and copy it to the clipboard (⌘ + C). (Alternatively, copy it from an existing app as described in steps 2 and 3.)
Right-click the .app file of which you want to change the icon and select “Get Info” (or select the file and press ⌘ + I).
Select the app icon in the top left corner by clicking it once. It will get a subtle blue outline if you did it right.
Now hit ⌘ + V (paste) to overwrite the default icon with the new one.