3 Replies Latest reply on Mar 1, 2010 5:46 PM by Sean_Wilson

    Need help with baXcopyProgress


      Hello everyone,


      I'm at wits end...really could use some help.


      Scenario: I have a bunch of audio files that will be in sub folders on the root of my multimedia DVD I'm developing that will need to be copied to the end users machine. I was turned onto baXcopyProgess from one of the community users last week and I've began trying to figure out a solution. I have purchased and registed Buddy API v 4.


      I have been able to get the following code to work successfully on a PC






      "C\Documents and Settings\HP_Administrator\My Documents\ClientProductName\Audio\MIDI")


      "C\Documents and Settings\HP_Administrator\Desktop\CopyFilesTest\MIDI files", "C\Documents and Settings\HP_Administrator\My Documents\Fender\Audio\WaveMP3", "*.mid", "IfNotExist", true, "Copying Files...", "Cancel", 0)





      First) I need to get the code to work by looking for the files to copy from themoviePath, which of course would start them at the root of the DVD. I can't seem to find the right way to do this...any help here would be greatly appreciated


      Second) How do I get to My Documents on a Macintosh, what is the appropriate syntax for telling it to copy the files to the MacHD and a predetermined location? I thought I saw this in code somewhere once as something like MacHD: Somepathinfo\morepathinfo but I'm not sure if this is different on every macintosh or not.


      Thank you in advance for any support you can provide


        • 1. Re: Need help with baXcopyProgress
          Sean_Wilson Adobe Community Professional

          Firstly, the 2 Buddy API functions you are using return values that you should monitor - they will tell you if an error occurred.


          It's not clear why you start by creating a folder, but I'll assume this is the target for your file copy operation. In most cases it's better to allow the user to choose their own folder, and this can be achieved with baGetFolder().


          In order to locate the user's "home" folder, on either WIndows or Mac, you would use baSysFolder("personal").


          Try the following:


          on mouseUp me
            -- place potential target folder into a local variable for later use:
            sDestinationFolder = baSysFolder("personal")
            -- give the end-user a chance to change the target folder:
            sDestinationFolder = baGetFolder(sDestinationFolder, "Choose a folder to copy into", 1 + 2, "Select a folder", -1, -1)
            -- did they choose a folder, or Cancel?
            if sDestinationFolder = EMPTY then
              -- they chose Cancel, so exit this handler:
            end if
            -- does the target folder exist? (it really should, since the folder-select dialog was used)
            if baFolderExists(sDestinationFolder) then
              -- let's create it
              bCreated = baCreateFolder(sDestinationFolder)
              -- check for error
              if bCreated <> 1 then
                -- folder creation failed, post an error message and exit:
                OK = baMsgBox("Failed to create destination folder", "Error", "OK", "stop", 1)
              end if
            end if
            -- we now have a target folder to copy into
            -- let's cache the folder containing the source files into a variable for ease-of-use:
            -- (assuming your MIDI files are in a folder named "midi" BESIDE the current movie
            -- alternatively, use _player.applicationPath to make a relative path from the projector)
            sSourceFolder = _movie.path & "midi"
            -- start copying
            bSuccess = baXCopyProgress(sSourceFolder, sDestinationFolder, "*.mid", "IfNotExist", TRUE, "Copying Files...", "Cancel", 0)
            -- check for error:
            if bSuccess <> 0 then
              -- see BudAPI docs for numbers and their meaning - the following is a direct copy
              case bSuccess of
                1: sMsg = "Invalid Source file name"
                2: sMsg = "Invalid Dest file name"
                3: sMsg = "Error reading the Source file"
                4: sMsg = "Error writing the Dest file"
                5: sMsg = "Couldn't create directory for Dest file"
                6: sMsg = "Dest file exists"
                7: sMsg = "Dest file is newer that Source file"
                8: sMsg = "No files matched the specified type"
                9: sMsg = "User cancelled the copy"
              end case
              -- post error message to user:
              OK = baMsgBox("Error copying files:" &RETURN& sMsg, "Error", "OK", "stop", 1)
            end if
          • 2. Re: Need help with baXcopyProgress
            Dignified_Dude Level 1

            Thanks Sean,


            Your code gave me something to work with. I'm a bit rusty on my lingo and scripting in Director. Never thought to define the string as a variable. As far as giving them a choice to copy the files to where they want I'm of the mindset that would be best, however the client software that they can choose to install points them to that location and for the quick burn turn around of this project they do not want to redo application installers or PDF manuals at this time...so you know how it goes. I advised the client of this idea of giving the end user the choice and was promptly told...not an option at this time.

            • 3. Re: Need help with baXcopyProgress
              Sean_Wilson Adobe Community Professional

              I advised the client of this idea of giving the end user the choice and was promptly told...not an option at this time.

              So is there any part of the puzzle you still need help with?