Results 1 to 6 of 6

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

  1. #1
    FLAC Sal R.'s Avatar
    Join Date
    Aug 2006
    Location
    Sun Diego
    Posts
    1,448

    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. #2
    Low Bitrate MOnline's Avatar
    Join Date
    Apr 2007
    Location
    Holland, Poeldijk (Near The Hague)
    Posts
    81
    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

  3. #3
    Mo' Programming Mo' Problems
    Auto Apps:loading...
    Sonicxtacy02's Avatar
    Join Date
    Sep 2004
    Location
    Woodbridge, VA
    Posts
    8,173
    Blog Entries
    53
    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.)
    Find my plugins on the MP3Car App Store!
    Follow Me on Twitter or Facebook
    Live mp3Car Facebook Chat

  4. #4
    FLAC Sal R.'s Avatar
    Join Date
    Aug 2006
    Location
    Sun Diego
    Posts
    1,448
    Quote 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.

    Quote 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

  5. #5
    FLAC Sal R.'s Avatar
    Join Date
    Aug 2006
    Location
    Sun Diego
    Posts
    1,448
    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

  6. #6
    Low Bitrate MOnline's Avatar
    Join Date
    Apr 2007
    Location
    Holland, Poeldijk (Near The Hague)
    Posts
    81
    Glad to hear it you solved the problem

    With kind regards,

    FG van Zeelst

Similar Threads

  1. Can someone make an autoit script for me?
    By Kamakazie2 in forum Software & Software Development
    Replies: 2
    Last Post: 12-23-2006, 07:37 PM
  2. Any AutoIt script experts out there?
    By mindracing in forum Centrafuse
    Replies: 8
    Last Post: 08-11-2005, 03:19 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •