Jump to content

me again, Xcopy


 Share

Recommended Posts

hello, me again :idiot:, iv got

$file = "c:\program files\microsoft games\halo"

Run('xcopy /e /h $file C:\temp', "", @SW_HIDE )

it doesnt seem to work, i think its the quoution marks, this works however.

Run('xcopy /e /h "c:\program files\microsoft games\halo" C:\temp', "", @SW_HIDE )

any help, id like to have it as a variable so i can change the file/directory, ty

qq

Link to comment
Share on other sites

Noobie :idiot:

just kiddin :D

Here's how you should do it.

(In order from good way to best way.)

Run('xcopy /e /h ' & $file & ' C:\temp', "", @SW_HIDE )
Run(@ComSpec & ' /c xcopy /e /h ' & $file & ' C:\temp', "", @SW_HIDE )
RunWait(@ComSpec & ' /c xcopy /e /h ' & $file & ' C:\temp', "", @SW_HIDE )
Link to comment
Share on other sites

Noobie :idiot:

just kiddin :D

Here's how you should do it.

(In order from good way to best way.)

Run('xcopy /e /h ' & $file & ' C:\temp', "", @SW_HIDE )
Run(@ComSpec & ' /c xcopy /e /h ' & $file & ' C:\temp', "", @SW_HIDE )
RunWait(@ComSpec & ' /c xcopy /e /h ' & $file & ' C:\temp', "", @SW_HIDE )

<{POST_SNAPBACK}>

i just tryed all 3 ways and none worked lol

qq

Link to comment
Share on other sites

Well, then use FileCopy.

Edit:

BTW, you have to add quotation marks if you specify a path with spaces.

Run('xcopy /e /h "' & $file & '" C:\temp', "", @SW_HIDE )
Run(@ComSpec & ' /c xcopy /e /h "' & $file & '" C:\temp', "", @SW_HIDE )
RunWait(@ComSpec & ' /c xcopy /e /h "' & $file & '" C:\temp', "", @SW_HIDE )
Edited by SlimShady
Link to comment
Share on other sites

Well, then use FileCopy.

<{POST_SNAPBACK}>

for wat im tryin to do i cant, need to run something while the file is copying, using filecopy waits till its finiched copying hen does it, i have to call an external prog like xcopy and do it, thanks for help

qq

Link to comment
Share on other sites

hi,

i think u need to put the \ at the end of the destination folder...

from the code SlimShady provided...

Run('xcopy /e /h ' & $file & ' C:\temp', "", @SW_HIDE )

Run(@ComSpec & ' /c xcopy /e /h ' & $file & ' C:\temp', "", @SW_HIDE )

RunWait(@ComSpec & ' /c xcopy /e /h ' & $file & ' C:\temp', "", @SW_HIDE )

this should be correct, hope i am not wrong...

Run('xcopy /e /h ' & $file & ' C:\temp\', "", @SW_HIDE )

Run(@ComSpec & ' /c xcopy /e /h ' & $file & ' C:\temp\', "", @SW_HIDE )

RunWait(@ComSpec & ' /c xcopy /e /h ' & $file & ' C:\temp\', "", @SW_HIDE )

:idiot:

New to script...But getting the hang of it.

Link to comment
Share on other sites

damn none of them work :idiot:, the only one that i know does work is the one im using.

Run('xcopy /e /h "c:\program files\microsoft games\halo" C:\temp', "", @SW_HIDE )

but doesnt use a variable, its annyong cause if i wanna compile this i wont be able to change it :D, i wanna make the variable a input box, maybe u just cant use variables :lol:

qq

Link to comment
Share on other sites

$origdirect = "c:\program files\microsoft games\halo"
$copydirect = "C:\temp"
$file = FileExists ("C:\temp")

If $file = 1 then 
      If msgbox(1, "Confirmation", "The directory already exists. Are you sure you 

want to replace it?") = 2 then
      Exit
      Else
      CopyFolder()
   EndIf
EndIf

If $file = 0 then 
      If msgbox(1, "Confirmation", "The specified directory doesnt exist. Would you 

like to create it?") = 1 then
      DirCreate ($copydirect)
      CopyFolder()
      Else
     Exit
   EndIf
EndIf

Func CopyFolder()

Run('xcopy /e /h "c:\program files\microsoft games\halo" C:\temp', "", @SW_HIDE ) 

ProgressOn("Progress Meter", "")

Do

$origfilesize = dirGetSize($origdirect)
$copyfilesize = dirGetSize($copydirect)
$MB = dirGetSize($copydirect) / 1024 / 1024

$percent = $copyfilesize / $origfilesize * 100

$decimalplace = Round ($percent)
$decimalplaceMB = Round ($MB)

ProgressSet ($percent, $decimalplace  & " % " & "(" & $decimalplaceMB & ") Mb has 

been copied.")

Until $copyfilesize = $origfilesize

ProgressOff ()

If $copyfilesize = $origfilesize then
Msgbox(0,"Complete", "All files and folders have been copied successfully.")
Else
Msgbox(0,"Error", "1 or more of the files/folders did not copy correctly.")
EndIf

EndFunc

ive also posted this in scripts and scraps under "Progress Bar", i just used halo and c:\temp to test it, you can change the directories and test yourself :idiot:

qq

Link to comment
Share on other sites

I see the problem. I'll try to fix it.

Hold on...

Edit:

I used the AutoIt folder for testing.

;$origdirect = "c:\program files\microsoft games\halo"

$origdirect = "C:\Program Files\AutoIt3"
$copydirect = "C:\temp"

If FileExists ($copydirect) then 
   If msgbox(1, "Confirmation", "The directory already exists. _
      Are you sure you want to replace it?") = 2 Then Exit
  ;Else
   CopyFolder($origdirect, $copydirect)
Else
   If msgbox(1, "Confirmation", "The specified directory _
      doesnt exist. Would you like to create it?") = 1 then
         DirCreate ($copydirect)
         CopyFolder($origdirect, $copydirect)
   Else
      Exit
   EndIf
EndIf

Func CopyFolder($Folder1, $Folder2)
   Local $ProcID
   $ProcID = Run(@ComSpec & ' /c xcopy /e /h /y "' & $Folder1 & '" "' & $Folder2 & '"', "", @SW_HIDE)
   
   ProgressOn("Progress Meter", "")
   
   $origfilesize = DirGetSize($Folder1)
   Do
   
      $copyfilesize = DirGetSize($Folder2)
      
      $MB = dirGetSize($Folder2) / 1024 / 1024
      
      $percent = $copyfilesize / $origfilesize * 100
      
      $decimalplace = Round ($percent)
      $decimalplaceMB = Round ($MB)
      
      ProgressSet ($percent, $decimalplace  & " % " & "(" & _
         $decimalplaceMB & ") Mb has been copied.")
   
      Sleep(500)
   Until NOT ProcessExists($ProcID)
   
   ProgressOff ()
   
   $copyfilesize = DirGetSize($Folder2)
   
   If $origfilesize = $copyfilesize then
      Msgbox(0,"Complete", "All files and folders have been copied successfully.")
   Else
      Msgbox(0,"Error", "1 or more of the files/folders did not copy correctly.")
   EndIf

EndFunc
Edited by SlimShady
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...