A Flash Developer Resource Site

Results 1 to 14 of 14

Thread: AppleScript? -- downloading files from CD to HD

  1. #1
    Senior Member
    Join Date
    Feb 2002
    Location
    Toledo,OH
    Posts
    143

    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.

  2. #2
    Lifetime Friend of Site Staff Northcode's Avatar
    Join Date
    Dec 2000
    Location
    Whitehorse YT
    Posts
    3,766
    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.

  3. #3
    Senior Member
    Join Date
    Feb 2002
    Location
    Toledo,OH
    Posts
    143
    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.

  4. #4
    Lifetime Friend of Site Staff Northcode's Avatar
    Join Date
    Dec 2000
    Location
    Whitehorse YT
    Posts
    3,766
    It's just a reference to an existing folder, there are other Finder calls you can make to create folders.

  5. #5
    Senior Member
    Join Date
    Feb 2002
    Location
    Toledo,OH
    Posts
    143
    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?

  6. #6
    Lifetime Friend of Site Staff Northcode's Avatar
    Join Date
    Dec 2000
    Location
    Whitehorse YT
    Posts
    3,766
    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.

  7. #7
    Senior Member
    Join Date
    Feb 2002
    Location
    Toledo,OH
    Posts
    143
    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!

  8. #8
    Lifetime Friend of Site Staff Northcode's Avatar
    Join Date
    Dec 2000
    Location
    Whitehorse YT
    Posts
    3,766
    Apple has a pretty good AppleScript Reference online. Chewing through it all to find what you need is another matter

  9. #9
    Senior Member
    Join Date
    Feb 2002
    Location
    Toledo,OH
    Posts
    143
    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?

  10. #10
    Senior Member
    Join Date
    Feb 2002
    Location
    Toledo,OH
    Posts
    143
    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.

  11. #11
    Lifetime Friend of Site Staff Northcode's Avatar
    Join Date
    Dec 2000
    Location
    Whitehorse YT
    Posts
    3,766
    Awesome, I'll add that to my knowledge base and tuck it away for next time. Thanks for posting back with a solution!

  12. #12
    Junior Member
    Join Date
    May 2004
    Posts
    1

    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.

  13. #13
    Lifetime Friend of Site Staff Northcode's Avatar
    Join Date
    Dec 2000
    Location
    Whitehorse YT
    Posts
    3,766
    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.

  14. #14
    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
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center