Jump to content

Easy Xcopy command


Laymanball
 Share

Recommended Posts

Share this code.

#NoTrayIcon
Opt("MustDeclareVars", 1)
Global $Source, $ssName, $Destin, $dsName, $btn
XcopyCommand()
Func XcopyCommand()
    $Source = FileSelectFolder("Select drive or folder to copy", @DesktopDir, 2)
    If Not $Source Then Exit
    $ssName = FileGetShortName($Source, 1)
    $Destin = FileSelectFolder("Select drive or folder to save", @DesktopDir, 1+2+4)
    If Not $Destin Then Exit
    $dsName = FileGetShortName($Destin, 1)
    If @error Then Exit
    $btn = MsgBox(36, "Copy confirm", "Do you wanted to copy?")
    If $btn = 7 Then Exit
    RunWait(@ComSpec & " /C"&' '&"Xcopy"&' '&$ssName&"\*.*"&' '&$dsName&" /S /E")
    MsgBox(64, "", "Completed")
EndFunc
Edited by Laymanball

My Sample Script

Download: VistaDesktopIconsChangerForXp.au3 (Com,Doc and Bin only) http://www.4shared.com/rar/NMHYL5Igba/VistaDesktopIconsChangerForXp_.html

                     VistaDesktopIconsChangerForXp.exe (Resources) http://www.4shared.com/rar/nzs7Mb1gba/VistaDesktopIconsChangerForXp_.html

Link to comment
Share on other sites

Add Wait! progress.

#NoTrayIcon
Opt("MustDeclareVars", 1)
Global $Source, $ssName, $Destin, $dsName, $btn, $pid
XcopyCommand()
Func XcopyCommand()
    $Source = FileSelectFolder("Select drive or folder to copy", @DesktopDir, 2)
    If Not $Source Then Exit
    $ssName = FileGetShortName($Source, 1)
    $Destin = FileSelectFolder("Select drive or folder to save", @DesktopDir, 1+2+4)
    If Not $Destin Then Exit
    $dsName = FileGetShortName($Destin, 1)
    If @error Then Exit
    $btn = MsgBox(36, "Copy confirm", "Do you wanted to copy?")
    If $btn = 7 Then Exit
    $pid = Run(@ComSpec & " /C"&' '&"Xcopy"&' '&$ssName&"\*.*"&' '&$dsName&" /S /E")
    WinWaitActive("[Class:ConsoleWindowClass]", "", 1)
    WinMove("[Class:ConsoleWindowClass]", "", 160, 180, 800, 400)
    ProgressOn("", "", "", 330, 300)
    Dim $i = 0
    While ProcessExists($pid)
        $i +=1
        ProgressSet($i, "Please wait!", "Copying...")
        If $i > 100 Then $i = 0
        Sleep(100)
        If ProcessExists($pid) = 0 Then
            ProgressSet(100, "", "")
            Sleep(500)
            ExitLoop
        EndIf
    WEnd
        ProgressOff()
        MsgBox(64, "", "Completed")
EndFunc

;===========================================================

Add ComObject Count Progress.

#NoTrayIcon
Opt("MustDeclareVars", 1)
Global $Source, $ssName, $Destin, $dsName, $btn, $pid, $search, $files
XcopyCommand()
Func XcopyCommand()
    $Source = FileSelectFolder("Select drive or folder to copy", @DesktopDir, 2)
    If Not $Source Then Exit
    $ssName = FileGetShortName($Source, 1)
    $Destin = FileSelectFolder("Select drive or folder to save", @DesktopDir, 1+2+4)
    If Not $Destin Then Exit
    $dsName = FileGetShortName($Destin, 1)
    If @error Then Exit
    $btn = MsgBox(36, "Copy confirm", "Do you wanted to copy?")
    If $btn = 7 Then Exit
    Dim $oAutoIt
    $oAutoIt = ObjCreate("AutoItX3.Control")
    $pid = $oAutoIt.Run("cmd" & " /C"&' '&"Xcopy"&' '&$ssName&"\*.*"&' '&$dsName&" /S /E")
    $oAutoIt.WinWaitActive("[Class:ConsoleWindowClass]", "", 1)
    $oAutoIt.WinMove("[Class:ConsoleWindowClass]", "", 160, 180, 800, 400)
    ProgressOn("", "", "", 330, 300)
    Dim $i = 0
    $search = FileFindFirstFile($Source&"\*.*")
    While $oAutoIt.ProcessExists($pid)
        $i +=1
        $files = FileFindNextFile($search)
        ProgressSet($i&$files, $files, "Copying...")
        If $i > 100 Then $i = 0
        Sleep(250)
        If $oAutoIt.ProcessExists($pid) = 0 Then
            ProgressSet(100, "", "")
            Sleep(500)
            ExitLoop
        EndIf
    WEnd
        FileClose($search)
        ProgressOff()
        MsgBox(64, "", "Completed")
EndFunc
Edited by Laymanball

My Sample Script

Download: VistaDesktopIconsChangerForXp.au3 (Com,Doc and Bin only) http://www.4shared.com/rar/NMHYL5Igba/VistaDesktopIconsChangerForXp_.html

                     VistaDesktopIconsChangerForXp.exe (Resources) http://www.4shared.com/rar/nzs7Mb1gba/VistaDesktopIconsChangerForXp_.html

Link to comment
Share on other sites

Add Wait! progress.

I think you're looking for the Marquee style of a progress bar.

GUICtrlCreateProgress(0, 0, -1, -1, $PBS_MARQUEE)

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

ฺBrewManNH

Thanks to the guidance.

But I am not a programmer.

Please write a sample with

Edited by Laymanball

My Sample Script

Download: VistaDesktopIconsChangerForXp.au3 (Com,Doc and Bin only) http://www.4shared.com/rar/NMHYL5Igba/VistaDesktopIconsChangerForXp_.html

                     VistaDesktopIconsChangerForXp.exe (Resources) http://www.4shared.com/rar/nzs7Mb1gba/VistaDesktopIconsChangerForXp_.html

Link to comment
Share on other sites

You must modify to Xcopy

Files Counter Progress

$source=FileSelectFolder("Choose a drive or folder.", @DesktopDir, 2)
If($source="")And(@error=1) Then Exit
$size=DirGetSize($source, 1+2)
$sizcou=($size[1]+$size[2])
MsgBox(0, "", "Step count = "&$sizcou)
$search=FileFindFirstFile($source&"\*")
$i=0
$count=""
ProgressOn("Counter Progress", "", "", 400, 300)
Do
    $i+=(100/$sizcou)
    $files=FileFindNextFile($search)
    $count=$count&$files&@CRLF
    ProgressSet($i, $files, "Loading.."&Round($i)&"%")
    If $files>=$sizcou Or $i > 100 Then
        ProgressSet(100, "Finish....................", "Loading..100%")
        ExitLoop
    EndIf
    Sleep(200)
Until $files==""Or $i==$sizcou
FileClose($search)
ToolTip("")
Sleep(500)
ProgressOff()
MsgBox(0, "", "Location: "&$source&@CRLF& _
              "All files: "&$sizcou&@CRLF& _
              "Files: "&$size[1]&@CRLF& _
              "Folder: "&$size[2]&@CRLF& _
              "==========Files list=========="&@CR&@LF&$count)

;======================================================================

Add array list.

#Include <File.au3>
#Include <Array.au3>

$source=FileSelectFolder("Choose a drive or folder.", @DesktopDir, 2)
If($source="")And(@error=1) Then Exit
$size=DirGetSize($source, 1+2)
$sizcou=($size[1]+$size[2])
MsgBox(0, "", "Step count = "&$sizcou)
$search=FileFindFirstFile($source&"\*")
$i=0
$count=""
ProgressOn("Counter Progress", "", "", 400, 300)
Do
    $i+=(100/$sizcou)
    $files=FileFindNextFile($search)
    ;$count=$count&$files&@CRLF
    ProgressSet($i, $files, "Loading.."&Round($i)&"%")
    Sleep(200)
    If $files>=$sizcou Or $i > 100 Then
        ProgressSet(100, "Finish....................", "Loading..100%")
        _CloseHandle()
        ExitLoop
    EndIf
Until $files==""Or $i==$sizcou

#cs MsgBox(0, "", "Location: "&$source&@CRLF& _
              "All files: "&$sizcou&@CRLF& _
              "Files: "&$size[1]&@CRLF& _
              "Folder: "&$size[2]&@CRLF& _
#ce              "==========Files list=========="&@CR&@LF&$count)
$flist=_FileListToArray($source)
If IsArray($flist)Then
    _ArrayDisplay($flist,"File List")
EndIf

Func _CloseHandle()
    FileClose($search)
    ToolTip("")
    Sleep(500)
    ProgressOff()
EndFunc
Edited by Laymanball

My Sample Script

Download: VistaDesktopIconsChangerForXp.au3 (Com,Doc and Bin only) http://www.4shared.com/rar/NMHYL5Igba/VistaDesktopIconsChangerForXp_.html

                     VistaDesktopIconsChangerForXp.exe (Resources) http://www.4shared.com/rar/nzs7Mb1gba/VistaDesktopIconsChangerForXp_.html

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...