Announcement

Collapse
No announcement yet.

Need help w/ AutoIT copy file/folder script...

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Need help w/ AutoIT copy file/folder script...

    $origin and $destination are defined in Road Runner and passed to the script.

    This piece of code works except for the fact if $origin folder has sub-directories, it won't get copied over to the path defined by $destination.

    Code:
    $origin = $rr.getinfo("=$origin$")
    $destination = $rr.getinfo("=$destination$")
    ;Get origin info - file or folder
    $originarray = StringSplit($origin, "\", 1)
    $originarraycount = $originarray[0]
    		
    $fileorfolder = StringInStr($originarray[$originarraycount], ".")	;Search string for "." to denote a file.  Otherwise, a folder
    		
    If $fileorfolder == 0 Then
    	;Commands to execute if origin is a folder
    	FileCopy($origin & "\*.*", $destination & $originarray[$originarraycount] & "\", 9)
    			
    	If FileExists($destination & $originarray[$originarraycount] & "\*.*") Then
    		$rr.execute("MENU;SUCCESS.skin||SETLABEL;!STATUS;Folder Copied")	;Confirmation skin
    	Else
    		$rr.execute("MENU;FAIL.skin||SETLABEL;!STATUS;Copy Failed!")		;Confirmation skin
    	EndIf
    			
    Else
    	;Commands to execute if origin is a file
    	;MsgBox(4096,"Drive ", "It's a file")
    	FileCopy($origin, $destination, 1)
    			
    	If FileExists($destination & $originarray[$originarraycount]) Then
    		$rr.execute("MENU;SUCCESS.skin||SETLABEL;!STATUS;File Copied")	;Confirmation skin
    	Else
    		$rr.execute("MENU;FAIL.skin||SETLABEL;!STATUS;ERROR! Copy Failed!")		;Confirmation skin
    	EndIf
    			
    EndIf
    I've been searching the autoIT help for a few hours now and can't find a solution that will work. The DirMove works, but it deletes the $origin folder.

    Any help would be greatly appreciated.
    Pico-ITX / XP Home with EWF-HORM / RR v12/02/2009 / Winamp v5.13 / RRMedia v1.2.2

  • #2
    Hi,

    When you copy only one file does this work.

    Because I can image that when you move an entire folder windows "recreates" it just like overwriting a file. If file copy works have you tried copying all the files in the folder instead of copying the folder itself ?

    With kind regards,

    FG van Zeelst
    Check out My Custom Frontend

    Comment


    • #3
      create a backup directory in the origin's location.. use dir move then after you've confirmed the move is complete just rename the backup to origins name. K.I.S.S Method ! lol
      mp3Car.com Senior Tech Blogger (Want a product reviewed? Contact me.)
      Follow Me on Twitter or Facebook
      Live mp3Car Facebook Chat

      Comment


      • #4
        Originally posted by MOnline View Post
        Hi,

        When you copy only one file does this work.

        Because I can image that when you move an entire folder windows "recreates" it just like overwriting a file. If file copy works have you tried copying all the files in the folder instead of copying the folder itself ?

        With kind regards,

        FG van Zeelst
        It copies all the files in the $origin directory.

        If there are subdirectories w/ files in the $origin, it won't get copied over, which is what I'm trying to do with just one copy command instead of multiple commands.

        Originally posted by Sonicxtacy02 View Post
        create a backup directory in the origin's location.. use dir move then after you've confirmed the move is complete just rename the backup to origins name. K.I.S.S Method ! lol
        So how do I create a backup using autoIT? I'd still have to make a backup copy of $origin before being able to use DirMove to $destination, right?
        Pico-ITX / XP Home with EWF-HORM / RR v12/02/2009 / Winamp v5.13 / RRMedia v1.2.2

        Comment


        • #5
          Problem solved.

          Found the DirCopy command...by accident when I mistakenly typed in xcopy.

          Lucky me.

          =)
          Pico-ITX / XP Home with EWF-HORM / RR v12/02/2009 / Winamp v5.13 / RRMedia v1.2.2

          Comment


          • #6
            Glad to hear it you solved the problem

            With kind regards,

            FG van Zeelst
            Check out My Custom Frontend

            Comment

            Working...
            X