-
AppleScript? -- downloading files from CD to HD
I saw in that big cross-platform PDF thread that NY Comet posted the Applescript commands that allow you to open files (like .jpg and .pdf) from Flash. I was wondering if there was a script that allows you to save a file to the user's harddrive much in the same way that Northcode's "copy2" utility works. I'm sorry but I'm a complete newbie when it comes to Applescript so i have no clue what the script would be. Any help would be greatly appreciated.
-
Lifetime Friend of Site Staff
There are a number of ways to specify the source and target files, but this is the basic kind of command you're looking for to copy files around:
Code:
tell application "Finder"
activate
copy file "me.jpg" of folder "Images" of disk "MyCD" to folder "Images" of startup disk
end tell
You can find more info about file references in Finder at Referring to items in the Finder
Last edited by Northcode; 03-29-2004 at 07:30 PM.
-
Thank you very much for the quick reply and the link. I'm going to have to read up on AppleScript a bit more. Just a quick question thou as i'm planning on implementing the code this afternoon, will that code you've provided automatically create a new folder on the desktop called "images"? Or is that just assuming that there's a folder called images already on the desktop? I know you can just reference to the desktop but I was curious.
-
Lifetime Friend of Site Staff
It's just a reference to an existing folder, there are other Finder calls you can make to create folders.
-
Thank you very much for the response, I've inputed the code for the Mac side, and I'm using your 2Desktop script for the PC side. Is there an easy way using AppleScript to create a simple system message to inform users that they've just downloaded a file to their desktop similar to the message that pops up using the /m command of the 2Desktop script? I've been searching for a day or two now and haven't had much luck at all finding useful AppleScript tutorials that do what I want to do.
Oh also Northcode, is it possible to use a relative path to the files from your 2Desktop utility or will using "/" in the path throw it off since it's using /f, /m, and /c as command prompts?
-
Lifetime Friend of Site Staff
The say command is what you want. Here's an example that just displays a "finished" message after a simple operation.
Code:
tell application "Finder"
empty trash
end tell
say "finished emptying the trash!"
The filespec argument to 2Desktop can be absolute or relative. In Windows/DOS applications "/" is not used as a path separator, that's a "\" so be sure to use "\" in your filespecs and you'll be okay. e.g. \files\friedcat.jpg and not /files/friedcat.jpg
Last edited by Northcode; 04-02-2004 at 02:21 PM.
-
ah ok thanks for that tip on the 2Desktop utility...I came up with a workaround but that definitely helps me make things run a bit smoother.
Also, thanks a lot for the AppleScript help....this is the first time I've ever tried using it and I'm really having problems finding decent documentation on some of the basic commands.
I really appreciate all the help!
-
Lifetime Friend of Site Staff
Apple has a pretty good AppleScript Reference online. Chewing through it all to find what you need is another matter
-
cool thanks for the link.
I tried the "say" code but couldn't get it to work. Here's what I had:
------------------------
try
tell application "Finder"
copy file "filename.pdf" of folder "foldername" of disk "diskname" to desktop
end tell
end try
say "filename.pdf has been downloaded to your desktop"
--------------------------
It still downloads the file to the desktop no problem, but I still get no system message. I've tried putting the say command where it is now and I've also tried putting it after "end tell" and before "end try". Any ideas why I'm getting no message?
-
Found it finally!
"say" didn't do anything for me, but using:
display dialog ("your message here")
worked like a charm. Although I really only wanted an "ok" button and there's also a "cancel" button on it...but hey it'll work for now.
-
Lifetime Friend of Site Staff
Awesome, I'll add that to my knowledge base and tuck it away for next time. Thanks for posting back with a solution!
-
file browser?
Is it possible to pop up a dialog box to let the user choose the location to which they can save the file? I've been trying Northcode's free tool (copy2) and trying his SWF Studio as well for PC, but I'm looking for a solution for MAC.
-
Lifetime Friend of Site Staff
Unless you're able to write Mac applications your salvation lies in scripting the Apple Finder application. You can check out the online AppleScript reference I pointed out above or take a look at http://www.scriptweb.com, the holy grail of AppleScript resources for the Mac.
Last edited by Northcode; 05-20-2004 at 07:07 PM.
-
Our 3rd party tool Fire-up will copy files and folders to the user's hard disk. It pops up a standard file save dialog and a standard progress bar while copying.
It works on Mac and Windows. You can download a trial version at http://www.atomiksoftware.com
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|