Jump to content
Sign in to follow this  
buzz44

me again, Xcopy

Recommended Posts

buzz44

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

Share this post


Link to post
Share on other sites
SlimShady

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 )

Share this post


Link to post
Share on other sites
buzz44

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

Share this post


Link to post
Share on other sites
SlimShady

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

Share this post


Link to post
Share on other sites
buzz44

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

Share this post


Link to post
Share on other sites
SlimShady

Oh. I see.

I don't know the switches of XCOPY. I bet you'll figure it out.

Share this post


Link to post
Share on other sites
jacky_ckw

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.

Share this post


Link to post
Share on other sites
buzz44

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

Share this post


Link to post
Share on other sites
ioliver

You should be able to use a variable. Can you post the rest of your code? Maybe, you are setting up the variable incorrectly.

Thanks,

Ian


"Blessed be the name of the Lord" - Job 1:21Check out Search IMF

Share this post


Link to post
Share on other sites
buzz44

$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

Share this post


Link to post
Share on other sites
SlimShady

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

Share this post


Link to post
Share on other sites
buzz44

thanks a bunch slim :idiot::), now i can add an input box or even better FileSelectFolder :D

thanks all for help :lol:


qq

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.