Sign in to follow this  
Followers 0
am632

Slight probem with xcopy to same directory

6 posts in this topic

Hi, I'd just like to say thanks to everyone who has already helped me, I know I ask alot of questions and I appreciate it much.

OK, I am trying to backup say the desktop - to a folder on the desktop.

Heres a snippet of ma code...

RunWait('xcopy.exe "' & $SETDESKTOPDIR & '" "' & $TEMPFOLDER & "\Desktop" & '" /e /c /h /r /k /y /d /i', @SystemDir, @SW_HIDE)
                RunWait('xcopy.exe "' & $TEMPFOLDER &"\Desktop" & '" "' & $DESTINATION & "\Desktop" & '" /e /c /h /r /k /y /d /i', @SystemDir, @SW_HIDE)

It works perfectly except it also backs up the backup folder to the desktop aswell.

for example, if the $Destionation = @DesktopDir & "\Backup", the backup will be backed up aswell. This is not an infinite loop tho, it just does it once. Do you get what i mean? I tried adding...

'/EXCLUDE' & $DESTINATION

to the xcopy but it didnt make any difference.

Any ideas?

thanks again everyone

Share this post


Link to post
Share on other sites



My suggestion is to copy it to a different location. If you wanted to, you can create a shortcut to the back up location and put that on your desktop instead. Or make sure there's a space between the /EXCLUDE and the folder name, because in your example there isn't one.


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

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Hi thanks for the reply.

I wuld like the backup directory to be completely 100% optional so the shortcut idea isnt for me but thanks anyway.

I tried putting the space after the exclude but i must have the line wrong because i get an error saying something like error in expression?

heres the code....

RunWait('xcopy.exe "' & $SETDESKTOPDIR & '" "' & $TEMPFOLDER & "\Desktop" & '" /e /c /h /r /k /y /d /i /EXCLUDE ' & $DESTINATION, @SystemDir, @SW_HIDE)

do you know where im going wrong?

thanks

EDIT actual error is, 'Illegal text at end of statement (one statement per line)

Edited by am632

Share this post


Link to post
Share on other sites

Sorry to post twice but pleaseee does anyone know how to add the exclude peram to this command?

thanks

Share this post


Link to post
Share on other sites

The correct way to use the /EXCLUDE option is

/EXCLUDE:C:\myExclueds.txt

C:\myExclueds.txt Should contain strings that partially match the directories or files you want xcopy to exclude.

Example:

\Backup\

.bak

.tmp

This would exclude any files with \Backup\ anywhere in the path to the file. plus any files with a .bak or .tmp extention


"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook

Share this post


Link to post
Share on other sites

Hi, thanks for that,

the problem is actually the variable i'm trying to use, i dont know how to 'seperate' it because if i put /exclude:$DESTINATION then the $DESTINATION bit is part of the string if u get what i mean? i need something like 'exclude: ' & $DESTINATION. do you get what i mean?

thanks

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  
Followers 0