Jump to content



Photo

Easy Xcopy command


  • Please log in to reply
4 replies to this topic

#1 Laymanball

Laymanball

    Wayfarer

  • Active Members
  • Pip
  • 66 posts

Posted 23 September 2011 - 12:52 AM

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, 23 September 2011 - 01:06 AM.








#2 Laymanball

Laymanball

    Wayfarer

  • Active Members
  • Pip
  • 66 posts

Posted 23 September 2011 - 01:47 AM

Add Wait! progress.

Plain Text         
#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.

Plain Text         
#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, 23 September 2011 - 04:51 PM.


#3 BrewManNH

BrewManNH

    באָבקעס מיט קודוצ׳ה

  • MVPs
  • 7,054 posts

Posted 23 September 2011 - 02:10 AM

Add Wait! progress.

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

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

How to ask questions the smart way!

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 editorGUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.

GUIToolTip UDF Demo - Demo script to show how to use the GUIToolTip UDF to create and use customized tooltips.

Posted Image


#4 Laymanball

Laymanball

    Wayfarer

  • Active Members
  • Pip
  • 66 posts

Posted 23 September 2011 - 02:27 AM

ฺBrewManNH

Thanks to the guidance.

But I am not a programmer.

Please write a sample with

Edited by Laymanball, 23 September 2011 - 02:29 AM.


#5 Laymanball

Laymanball

    Wayfarer

  • Active Members
  • Pip
  • 66 posts

Posted 23 September 2011 - 10:24 PM

You must modify to Xcopy

Files Counter Progress
Plain Text         
$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.

Plain Text         
#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, 24 September 2011 - 12:32 AM.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users