Skip to content

Instantly share code, notes, and snippets.

@codejake
Created July 28, 2026 21:30
Show Gist options
  • Select an option

  • Save codejake/3aa2e269b42fb73a908f3e6085e5756c to your computer and use it in GitHub Desktop.

Select an option

Save codejake/3aa2e269b42fb73a908f3e6085e5756c to your computer and use it in GitHub Desktop.
new-text-file.applescript
on run {input, parameters}
tell application "Finder"
if (count of Finder windows) > 0 then
set destinationFolder to target of front Finder window
else
set destinationFolder to desktop
end if
set fileName to "Untitled.txt"
set counter to 2
repeat while exists file fileName of destinationFolder
set fileName to "Untitled " & counter & ".txt"
set counter to counter + 1
end repeat
set newFile to make new file at destinationFolder ¬
with properties {name:fileName}
select newFile
activate
end tell
return input
end run
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment