Where to write temporary files?

If I have a script that needs to write temporary files while it works, is there a “standard” location for such files to go?

Right now just testing on my desktop, but would prefer to hide them during the normal function of the script.


there is a standard location

path to temporary items

Nice and easy…thanks!


Just for the sake of completeness:

path to temporary items from user domain

This returns the temporary items folder of the current user.

Best regards from cloudy-cold Berlin,


So in practice what is the difference in using the user domain version rather that the “path to temporary items” version? I’ve used “path to temporary items” will no apparent ill effects, other than the path that is returned is something like “Macintosh HD:private:var:folders:Rc:RcA68ahPFN8khL25MNw4k++++TQ:TemporaryItems:” (and the string of numbers in the middle is not always the same) but if you open it up in the Finder the path is more normal looking. It also appears this folder is the one many other apps use to store temp items.

Using the user domain version seem to make more sense, but I am curious if there are any things I would need to know before I switched all my existing scripts to use it.