Jump to content

Yet Another Progress Bar And DirCopy


Recommended Posts

Having problems with this, despite searching through the forums

I read in one of the threads to use FileCopy resursively. How, I have no clue.

I'm putting my code up, so one of you advanced beings can nudge me into the right direction

#include <File.au3>

$UserSettingsFile = "UserSettings.ini"
$Source = IniRead($UserSettingsFile,"Paths","SourcePath","Path Not Found")

;COPY SOURCE FROM DVD
$DVDSource = FileSelectFolder("Browse For DVD Root","",1,"::{20D04FE0-3AEA-1069-A2D8-08002B30309D}","SecondPage")
If @error Then
    MsgBox(4096,"","No DVD Root Chosen")
Else
;BASICALLY ALL FOR A PROGRESS BAR
    $FILE = _FileListToArray($DVDSource)
    ProgressOn("","Copying",$DVDSource & " to " & $Source)
    For $INDEX = 1 To $FILE[0]
        FileCopy($DVDSource & "\" & $FILE[$INDEX],$Source & "\" & $FILE[$INDEX],9)
        ProgressSet($INDEX*100/Number($FILE[0]),$DVDSource & "\" & $FILE[$INDEX] & " to " & @CRLF & $Source & "\" & $FILE[$INDEX])
    Next
    ProgressOff()
    FileCopy(
;DirCopy($DVDSource,$Source,1)
EndIf

Trouble is, it ends right after it asks for the $DVDSource - gives an error on the FileCopy line. Error parsing function call, it says.

Thanks in advance

Oh, also, I forgot to mention, the $DVDSource will definitely have more than one folder, which will need to be copied over.

Edited by niteshade
Link to comment
Share on other sites

it should be

FileCopy($DVDSource & "\" & $FILE[$INDEX],$Source & "\" & $FILE[$INDEX],8)
if u want to create directory structure in destination. not 9. better use scite4autoit. thats easier to use.
I am using it. And it still doesn't work. The progress bar pops up for a split second, then it gives an error - which I believe is when the $FILE array with a folder name is loaded, seeing as there are two empty files that copy over with the name of the folders on the actual source.

I'm using FileCopy as shown here because of the examples I saw when I was searching the forum. I can get the entire thing to copy using DirCopy, but I don't know how to make a progress bar out of it.

Edited by niteshade
Link to comment
Share on other sites

#include <File.au3>

$UserSettingsFile = "UserSettings.ini"
$Source = IniRead($UserSettingsFile,"Paths","SourcePath","Path Not Found")

;COPY SOURCE FROM DVD
$DVDSource = FileSelectFolder("Browse For DVD Root","",1,"::{20D04FE0-3AEA-1069-A2D8-08002B30309D}","SecondPage")

If @error Then
    MsgBox(4096,"","No DVD Root Chosen")
Else
    ;BASICALLY ALL FOR A PROGRESS BAR
    $FILE = _FileListToArray($DVDSource)
    If IsArray($FILE) then              
            ProgressOn("","Copying",$DVDSource & " to " & $Source)
            For $INDEX = 1 To $FILE[0]
                _CopyFromDisc($INDEX) ; 9 overwrites if files exist which we may not need here.
                ProgressSet($INDEX*100/Number($FILE[0]),$DVDSource & "\" & $FILE[$INDEX] & " to " & @CRLF & $Source & "\" & $FILE[$INDEX])
            Next
            Msgbox(0,"","completed")
            ProgressOff()
            
        Else
            Msgbox(0,"", "Nothing Found copiable!")
            EndIf
;DirCopy($DVDSource,$Source,1)
EndIf


Func _CopyFromDisc($i)
    $ret = FileCopy($DVDSource & "\" & $FILE[$i], $Source & "\" & $FILE[$i] , 9) ; 9 overwrites if files exist which we may not need here.
    If $ret = 1 then 
        $ret = " Copied successfully"
    Else  
        $ret = " Operation Failed"
    EndIf
    ConsoleWrite( @CRLF & $i & " " & @TAB & "Copying : " & $FILE[$i] & $ret )
EndFunc

this works perfectly for me, just in this case i have added _CopyFromDisc to let u see the output thats all. when u get this working just replace that line with what u had earlier, it would work. the basic thing is that i am checking if there are any files available for copying or else, it will just notify user, instead of throwing an error.

Link to comment
Share on other sites

what is it are you able to see in the console window? i wonder if it was due to bad media or something similar? autoit3.exe might have crashed and quit ? that is a possibility.

Well I don't see anything at all in the console window. I don't think its bad media - I'm using a mounted ISO, and it works fine. Here's a bit of code that I edited, seems to do the job halfway

;COPY SOURCE FROM DVD
$DVDSource = FileSelectFolder("Browse For DVD Root","",1,"::{20D04FE0-3AEA-1069-A2D8-08002B30309D}","SecondPage")
If @error Then
    MsgBox(4096,"","No DVD Root Chosen")
Else
;BASICALLY ALL FOR A PROGRESS BAR
    $FILE = _FileListToArray($DVDSource)
    ProgressOn("Copying Files","Copying",$DVDSource & " to " & $Source)
    For $INDEX = 1 To $FILE[0]
        DirCopy ($DVDSource & "\" & $FILE[$INDEX],$Source & "\" & $FILE[$INDEX],1)
        FileCopy($DVDSource & "\" & $FILE[$INDEX],$Source & "\" & $FILE[$INDEX],8)
        ProgressSet($INDEX*100/Number($FILE[0]),$DVDSource & "\" & $FILE[$INDEX] & " to " & @CRLF & $Source & "\" & $FILE[$INDEX])
    Next
    ProgressOff()
EndIf
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...