themotza Posted June 3, 2006 Share Posted June 3, 2006 How should be the /exclude feature used. i can't find right syntax. Can anyone give me an example, how to exclude a dir. For example i want to copy opera profile to directory C:\XP without directories cache4 and images. Link to comment Share on other sites More sharing options...
gdkehl Posted June 3, 2006 Share Posted June 3, 2006 this is from xcopy help /EXCLUDE:file1[+file2][+file3]... Specifies a list of files containing strings. Each string should be in a separate line in the files. When any of the strings match any part of the absolute path of the file to be copied, that file will be excluded from being copied. For example, specifying a string like \obj\ or .obj will exclude all files underneath the directory obj or all files with the .obj extension respectively.so; what command do you have so far? add the /exclude:file (or dir) Link to comment Share on other sites More sharing options...
themotza Posted June 4, 2006 Author Share Posted June 4, 2006 so far i havexcopy /Y "C:\Documents and Settings\Kristjan\Application Data\Opera\Opera\profile" "D:\$OEM$\$1\Install\Opera\profile" /I /E So how should i add /exclude if i don't want cache4 and images form opera profile to be copied. Link to comment Share on other sites More sharing options...
Yzöwl Posted June 4, 2006 Share Posted June 4, 2006 (edited) Try this:@ECHO OFF:: Create an exclude file>XCLUDE.TXT ECHO \cache4\>>XCLUDE.TXT ECHO \images\:: Copy the files and directoriesXCOPY "%APPDATA%\OPERA\OPERA\PROFILE" "D:\$OEM$\$1\Install\Opera\profile" /EIQHKOY/EXCLUDE:XCLUDE.TXT:: Delete the exclude fileDEL XCLUDE.TXTGOTO :EOF<Edit>Just as a side note, since you are using the $Docs structure, you will probably not want the /O switch. i.e. /EIQHKY/EXCLUDE:XCLUDE.TXT</Edit> Edited June 4, 2006 by Yzöwl Link to comment Share on other sites More sharing options...
Andromeda43 Posted June 4, 2006 Share Posted June 4, 2006 Just a thought......If you don't want to copy a certain subdirectory but you DO want to keep it, you could simply move it to a different location, then do the xcopy and then move it back,,,all within the same batch file.Or, you could even just let xcopy duplicate the whole tree structure and then delete the info you don't want....still from within the same batch file.Sometimes when I want to do something but I don't know exactly how to do it directly, I develope a "Work Around". This is one of them cases.I love XCopy, but it does have a few limitations.Good Luck,Andromeda43 B) Link to comment Share on other sites More sharing options...
maxXPsoft Posted June 4, 2006 Share Posted June 4, 2006 (edited) Use the best file copy app MS ever made, RobocopyI copy my Firefox Dir as a test here going to C:\Test not adding bookmarkbackups and chrome Folderrobocopy "%APPDATA%\Mozilla\Firefox" /MIR /V C:\Test /XD bookmarkbackups chrome /R:0/MIR Means Mirror and the /V is VerifyI also added the /R:0 because I'm using Firefox right now and I don't want it to retry any, you can change that to a 1 or whatever, otherwise it tries like a million timesI'm just guessin since I don't have Opera on hererobocopy "%APPDATA%\OPERA\OPERA\PROFILE" /MIR /V "D:\$OEM$\$1\Install\Opera\profile" /XD cache4 imagesShutdown Opera and then you don't need the /R: <<retryNo Need for any extra BS there as you see and all in one lineNOTE: /MIR will compare and delete what don't match REGARDLESS, read the readme Edited June 4, 2006 by maxXPsoft Link to comment Share on other sites More sharing options...
Yzöwl Posted June 4, 2006 Share Posted June 4, 2006 maxXPsoft, as much as your information is good, and as much as I like robocopy, it's not really warranted on this occasion.The Subject :Xcopy in batch fileThe question:How should be the /exclude feature used. i can't find right syntax. Can anyone give me an example, how to exclude a dir.I answered the question, hopefully well enough for a little thought and a little understanding. I used xcopy in a batch file with the /exclude feature usingthe questioners directories and a few comments.If I were to ask, what registry setting do I need for…someone will probably say 'use nlite'If I asked, how do I fix … in Internet Explorer?someone is guaranteed to say 'get Firefox'If I asked, how do I do … in a batch file?someone will likely say 'here's a vbscript'There's nothing wrong with offering alternatives, but maybe 'in answer' as opposed to 'as answer' would be better. Link to comment Share on other sites More sharing options...
maxXPsoft Posted June 5, 2006 Share Posted June 5, 2006 I have used robocopy for exact same thing with the exclude and knew how simple it is, I do know Xcopy problem's I've had so no more of that mess here if I can replace with the Robo.Offering an alternative is part of what this Forum is all about, the discoveries of new techniques.He can decide which, its up to him. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now