Making up a file name
Making up a file name
- Subject: Making up a file name
- From: Jan Erik Moström <email@hidden>
- Date: Thu, 09 Mar 2017 12:57:31 +0100
- Authorized-sender: email@hidden
Hi,
It has been many years since I wrote an applescript longer than 2 lines
so be kind.
I want to create a file and I want it to have the name "todays date +
random text string", i.e. something like this
"2017-03-09-svnszfvjsckvtte"
After looking at the web I wrote the code below. The problem is that the
existFile function always return true, no matter if the file actually
exists or not.
I assume I'm missing something really basic but I can't figure out what?
on makeFileName(todaysDate, basePath)
set fn to ""
repeat 15 times
set fn to fn & (character id (random number from 97 to 122))
end repeat
return POSIX file (basePath & (the short date string of todaysDate) &
"-" & fn)
end makeFileName
on existFile(fp)
log fp as text
tell application "System Events"
return exists fp
end tell
end existFile
set td to (current date)
set destFile to makeFileName(td, "/Users/jem/Desktop/")
existFile(destFile)
Can anyone give me a hint what I'm missing?
= jem
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden