Effectively create temp folder in temp Items of user domain


set folderName to quoted form of "myRandomNameFolder"
set _tempFolder to do shell script "mktemp -d -t " & folderName

-- The code bellow is only to make visible result of code above
tell application "Finder"
	activate
	select (_tempFolder as POSIX file)
end tell
delay 10

Here’s an alternative using ASObjC and a UUID:

use framework "Foundation"
use scripting additions

set fileManager to current application's NSFileManager's defaultManager()
set theURL to fileManager's temporaryDirectory()'s URLByAppendingPathComponent:(current application's NSUUID's UUID()'s UUIDString())
fileManager's createDirectoryAtURL:theURL withIntermediateDirectories:true attributes:(missing value) |error|:(missing value)
return theURL's |path|() as string

A little more anonymity and speed.

Thanks Snane for your code. Your code will come in handy in many scripts, as this is one of the fundamental tricks of every programmer. I will keep both successful variants in my library. And… your variant is, of course, better. :slight_smile:

Most of all I liked the name of the folder. Here it is: “C0D92014-CD4B-4CD9-9CED-526240E1C249.”

That’s a UUID, or universally unique identifier. It’s a 128-bit number that’s unique for practical purposes.