Jump to content
Sign in to follow this  
Stuempi

xcopy with variables

Recommended Posts

Stuempi

Hi there,

I'm pretty new to all this, so please don't hit me if this question is too simple :D

I want to run xcopy via autoit and the variable has to be a part of the path from which to copy the files from...

RunWait("xcopy C:\test\all\all " & $Variable1 & $Variable2 & "/e /y /r")

RunWait("xcopy 'C:\test\' & $Variable3 & '\' & $Variable4 & " & $Variable1 & $Variable2 & "/e /y /r")

The first code is working so I don't think that anything is amiss with the variables... but I'm a bit clueless how to put the variables into the path of the source... :D

Variable 1 is something like C:\test2\

Variable 2 is something like ZZZZZ

Variable 3 is something like 01

Variable 4 is something like 1

for example: xcopy C:\test\01\1 C:\test2\ZZZZZ /e /y /r

Hope you get me... and can help me :o

Share this post


Link to post
Share on other sites
Jos

First example is missing a space before /e

RunWait("xcopy C:\test\all\all " & $Variable1 & $Variable2 & " /e /y /r")

Seconds one something like:

RunWait('xcopy "C:\test\' & $Variable3 & '\' & $Variable4 & '" "' & $Variable1 & $Variable2 & '"/e /y /r')

Jos


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
Stuempi

gnaaaa... I nearly got it myself!

Thank you very much, saved my day :D

Share this post


Link to post
Share on other sites
Stuempi

Hey...

I got the same kind of problem again... is there any tutorial on how to " and ' those variables?! I didn't find anything useful :D

So again I want to do some xcopy on paths which are variable... this time a bit diffrent:

RunWait('xcopy "C:\test\' & $file & '.exe' & '" "' & $Pfad & $pfadu & '" "' & '/e /y /r"')

$pfad is something like "C:\test2\" and $pfadu is something like "test\test\"

I would be very grateful if someone could help me on this :/

Share this post


Link to post
Share on other sites
SmOke_N

Hey...

I got the same kind of problem again... is there any tutorial on how to " and ' those variables?! I didn't find anything useful :D

So again I want to do some xcopy on paths which are variable... this time a bit diffrent:

RunWait('xcopy "C:\test\' & $file & '.exe' & '" "' & $Pfad & $pfadu & '" "' & '/e /y /r"')

$pfad is something like "C:\test2\" and $pfadu is something like "test\test\"

I would be very grateful if someone could help me on this :/

You could use double-double quotes if it makes it easier. No idea what the vars are, so you may need a space between the two $P+ vars:
RunWait("xcopy """ & @HomeDrive & "\test\" & $file & ".exe"" " & $Pfad & $pfadu & " /e /y /r")

Easiest way to see if you've done it correctly is to view it first:

MsgBox(64, "View Quotes", "xcopy """ & @HomeDrive & "\test\" & $file & ".exe"" " & $Pfad & $pfadu & " /e /y /r")
After practicing with singlequotes/double/and double-single/double quotes, you'll become a quote Jedi

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites
Stuempi

Hey Smoke,

thanks for another fast answer :D

... but that didn't work for me. I tried some more with a collegue and the following line worked for me:

RunWait('xcopy "C:\test' & $file & '.exe"' & ' "' & $Pfad & $pfadu & '" ' & '/e /y /r')

But I think the msgbox tip might come in handy :o

Thank you for this!

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  

×