This will probably sound very simple, but I’m rather desperate!
I want an Applescript that will grab the contents of the clipboard and place it into a TextEdit file in a particular folder, with some kind of incremental naming so that the file doesn’t get written over.
That’s it, really. I guess it would be good if the thing could handle images using rtfd, but that would be icing on the cake.
tell (current date) to set myDate to ((day of it) & "-" & (month of it) & "-" & (year of it) & "**" & (hours of it) & "-" & (minutes of it) & "-" & (seconds of it)) as string
set fileName to ("Clipboard (" & myDate & ")") as string
set fileContainer to (path to desktop) as alias -- insert your folder here
tell application "Finder" to make new file at fileContainer with properties {name:fileName}
set newFile to result as alias
set myData to the clipboard
try
set OA to open for access newFile with write permission
write myData to OA
close access OA
on error
try
close access OA
end try
end try
both coercions are useless, path to folder returns always an alias
set fileName to ("Clipboard (" & myDate & ")")
set fileContainer to path to desktop -- insert your folder here
the Finder is not needed to create the file, open for access does this automatically.
This is sufficient
set myDate to do shell script "/bin/date +%d%b%Y_%H%M%S"
set newFile to (path to desktop as text) & "Clipboard (" & myDate & ")"
set myData to the clipboard
try
set OA to open for access file newFile with write permission
write myData to OA
close access OA
on error
try
close access file newFile
end try
end try