Make a file a Stationery pad via command line

Is there a way to set make a file into a Stationery pad from the command line?

You can do it by clicking "Get info" on a file and checking the box, but I would like to do it without clicking.

Get Info dialog

An AppleScript solution would be useful also, but GUI scripting is off limits.


The SetFile utility is provided with Xcode, which Apple distributes at no cost. Once you have installed Xcode, you can issue the command

SetFile -a T /path/to/foo.bar

After failing to find a non-AppleScript way to do this, I bit the bullet.

The AppleScript:

 tell application "Finder" to set stationery of ¬
   (POSIX file "/path/to/foo.bar" as alias) to true

You can run this from the command line using

osascript -e command