Sign in to follow this  
Followers 0
sachit64

Automatic download of folder to USB key

2 posts in this topic

#1 ·  Posted (edited)

I asked some people if they knew of a program where I could plug in my USB key to the computer and it would automatically download a specific folders contents. They said there was no such program, but a batch file could easily be made and this is the program they directed me to. Problem is, I can't code.

I'm constantly going to computers in the building and copying ONE single folder from their computer and transporting it back to my work place. The file path is the exact same for all of them.

I was wondering if someone would be able to make a script I could run that would automatically copy a said folder to my USB key.

Anyone?

EDIT: Did some searching and found this. I'm pretty sure this would be a small script.

http://www.autoitscript.com/autoit3/docs/f...ons/DirCopy.htm

If it runs automatically as I plug in my USB key... all the better. If not, it would be nice to just have to run a small script and transfer the files discretly as the user keeps working on their stuff.

Edited by sachit64

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

I'm being a bit of a posting whore with my progresscopy.. try this it worked OK on my laptop, you need to compile it with the beta version

#include <GUIConstants.au3>

Global $Run1 = 0, $tosearch, $OverallQty, $Overall, $source, $overallpercent, $Progress0Text, $progressbar1, $Progress1Text, $progressbar2, $Progress2Text
While 1

If DriveStatus ( "f:" ) = "READY" Then  ;replace these paths with what you require
    ProgressCopy("d:\Kiosk","F:\")   ;replace these paths with what you require
    MsgBox (0,"Complete", "Copy copmplete, remove pendrive")
Endif   
Sleep (1000)
Wend

   
Func ProgressCopy($current,$destination)
    
;FirstTimeRun Get original DirSize and set up Gui
    If $Run1 = 0 then
        $Source = $Current
        If StringRight($current, 1) = '\' Then $current = StringtrimRight( $current, 1 )
        If StringRight($destination, 1) = '\' Then $destination = StringtrimRight( $destination, 1 ) 
        $tosearch = $current
        $Overall = DirGetSize ($tosearch, 1)
        $OverallQty = $Overall[1]
        $Gui = GUICreate("Copying Files",420,100, -1,-1,-1, $WS_EX_TOOLWINDOW + $WS_EX_TOPMOST)
        $Progress0Text = GUICtrlCreateLabel ( "Please Wait", 10, 5 , 400 , 20, $SS_LEFTNOWORDWRAP  )
        $progressbar1 = GUICtrlCreateProgress (10,20,400,20)
        GUICtrlSetColor(-1,32250)
        $Progress1Text = GUICtrlCreateLabel ( "", 10, 44 , 400 , 20, $SS_LEFTNOWORDWRAP  )
        $progressbar2 = GUICtrlCreateProgress (10,60,400,20, $PBS_SMOOTH )
        $Progress2Text = GUICtrlCreateLabel ( "", 10, 82 , 400 , 20, $SS_LEFTNOWORDWRAP  )
        GUISetFont (10, 600 )
        $Progress2Text2 = GUICtrlCreateLabel ( "", 150, 62 , 400 , 20  )
        GUICtrlSetColor(-1,0xffffff); not working with Windows XP Style if not using windows classic style
        GUISetState (@SW_Show)
        GUICtrlSetData ($progress1Text,"Working Directory " & $tosearch)
        $Run1 = 1
    Endif
    
    $Size = DirGetSize ($current, 3)
    $Qty = $Size[1]
    Local $search = FileFindFirstFile($current & "\*.*")
    While 1
    Dim $file = FileFindNextFile($search)
    If @error Or StringLen($file)<1 Then ExitLoop
    If not StringInStr(FileGetAttrib($current & "\" & $file),"D") And ( $file <> "." Or $file <> ".." ) then 
        $Qty -=1
        $LocalPercent =100 -( ($Qty / $Size[1]) * 100)
        $OverallQty -=1
        $OverallPercent =100 -( ($OverallQty / $Overall[1]) * 100)
        GUICtrlSetData ($progress0Text, "Total Progress " & Int ( $OverallPercent ) & "% completed")
        GUICtrlSetData ($progressbar1, $OverallPercent)
        GUICtrlSetData ($progressbar2, $LocalPercent)
        GUICtrlSetData ($progress2Text,"Copying File " & $file)
        FileCopy($current & "\" & $file, $destination & StringTrimLeft ($Current, Stringlen ($Source)) & "\" & $File)
        FileSetAttrib ($destination & StringTrimLeft ($Current, Stringlen ($Source)) & "\" & $File, "-R")
        Endif
    If StringInStr(FileGetAttrib($current & "\" & $file),"D") And ( $file <> "." Or $file <> ".." ) Then 
        DirCreate ($destination & StringTrimLeft ($Current, Stringlen ($Source))& "\" & $File)
        FileSetAttrib ($destination & StringTrimLeft ($Current, Stringlen ($Source))& "\" & $File, "-R")
        GUICtrlSetData ($progress1Text, $current & "\" & $file)
        ProgressCopy($current & "\" & $file,$destination)
        Endif
    WEnd
    FileClose($search)
;when overall percent = 100 set end gui text, delete gui and reset run1 to 0
        If $OverallPercent = 100 then
        GUICtrlSetData ($progress0Text, "Total Progress 100% completed")
        GUICtrlSetData ($progressbar1, 100)
        GUICtrlSetData ($progressbar2, 100)
        GUICtrlSetData ($progress2Text,"Done!")
        Sleep (2000)
    GUIDelete($Gui)
    $Run1 = 0
    Endif
EndFunc
Edited by ChrisL

Share this post


Link to post
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
Sign in to follow this  
Followers 0