• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
funny pair of scripts
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

funny pair of scripts


  • Subject: funny pair of scripts
  • From: Nelson Byrne <email@hidden>
  • Date: Mon, 8 Mar 2004 20:26:23 -0800

This fails if I choose my desktop, so that "choose folder as text" returns the string "OSX:Users:rnb:Desktop:"

property TheFileName : "debug.log"
(choose folder) as text returning TheFolder
log class of TheFolder
log TheFolder
tell application "Finder"
if (exists file (TheFolder & TheFileName)) then (delete file (TheFolder & TheFileName))
make new file at TheFolder with properties {name:TheFileName, owner privileges:read write, group privileges:read write, everyones privileges:read write} returning TrueFile
end tell

and the Event Log contains

tell current application
choose folder
alias "OSX:Users:rnb:Desktop:"
(*string*)
(*OSX:Users:rnb:Desktop:*)
end tell
tell application "Finder"
exists file "OSX:Users:rnb:Desktop:debug.log"
true
delete file "OSX:Users:rnb:Desktop:debug.log"
document file "debug copy 2.log" of trash
make new file at "OSX:Users:rnb:Desktop:" with properties {name:"debug.log", owner privileges:read write, group privileges:read write, everyones privileges:read write}
"Finder got an error: Can't make a file."
===================

This on the other hand works just fine:

property TheFileName : "debug.log"
property TheFolder : "OSX:Users:rnb:Desktop:"
log class of TheFolder
log TheFolder
tell application "Finder"
if (exists file (TheFolder & TheFileName)) then delete file (TheFolder & TheFileName)
make new document file at TheFolder with properties {name:TheFileName, owner privileges:read write, group privileges:read write, everyones privileges:read write} returning TrueFile
end tell

and returns the Event Log:

(*string*)
(*OSX:Users:rnb:Desktop:*)
tell application "Finder"
exists file "OSX:Users:rnb:Desktop:debug.log"
true
delete file "OSX:Users:rnb:Desktop:debug.log"
document file "debug copy 3.log" of trash
make new document file at "OSX:Users:rnb:Desktop:" with properties {name:"debug.log", owner privileges:read write, group privileges:read write, everyones privileges:read write}
document file "debug.log" of folder "Desktop" of folder "rnb" of folder "Users" of startup disk
end tell

================

What's going on here? In one case I generate the string locating the folder by running the choose folder as text command, in the other I simply supply it. Obviously I'd like to be able to choose on the fly rather than rewriting and recompiling the script for each possible folder, but it seems I cannot.

Comments very welcome.

Nelson Byrne
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.


  • Prev by Date: Re: TechNote 2106
  • Next by Date: Re: modifying default behavior of buttons in Mail.app
  • Previous by thread: nested folders
  • Next by thread: Re: funny pair of scripts
  • Index(es):
    • Date
    • Thread