![]()
[<<]Message[>>] [<<]Author[>>] [<<]Subject[>>] Thread[>>]
Number : 265 Date : 2001-06-21 Author : Gabe Fineman Subject : Re: Multi-step XXCOPY operations Size(KB) : 18
------_=_NextPart_001_01C0FAA5.68641070 Content-Type: text/plain Thank you for the excellent and detailed reply. Everything seems to work fine, with one puzzling exception. The command xxcopy /ce e:\asivasrv\ e:\xxtmp\ /s/h/rsy/pd0/u results in lines like the following as output for every directory: E:\ASIVASRV\D$ RmDir failed The directories are not deleted, so no harm is done, but I am not sure why it is trying to delete them since they are not hidden. Perhaps we should have used /ATH instead of /H, since the two may be synonymous but still not be identical. The /H switch, as you explained in Bulletin #4 is best thought of as "/H does not exclude hidden/system files" while the /ATH switch "selects ... files by the file attributes" (Bulletin #27). Perhaps it is just semantics. I vaguely remember using a shareware program called Robocopy decades ago to do backup in DOS and struggling mightily with its array of confusing switches and only sporadic bulletin board support. Not only is xxcopy clear and logical but it is well documented and has the best support (Kan) around. -Gabe Fineman -----Original Message----- From: Kan Yabumoto [mailto:tech.xxcopy@d...] Sent: Thursday, June 21, 2001 12:00 PM To: xxcopy@yahoogroups.com Subject: [xxcopy] Multi-step XXCOPY operations This message is a response to Gabe Fineman's excellent question on how to handle a complicated file-selection job which XXCOPY cannot handle. But, a multiple-step (batch file) solution is presented which can be applied to many other cases where XXCOPY cannot process certain combination of file-selection in one step. Here's Gabe's original question: >I have read Bulletin 17 on selecting files by date and still have a >question. I would like to delete files that meet three conditions > >1. They are marked as hidden >2. They were created more than 40 days ago (copied to this directory) >3. They have not been modified within the last 40 days > >I meet the first two conditions with the following command > >XXCOPY E:\Asivasrv\ /S/HO/Q1/YY /RS /ATH /FC/DB#40 > >I used the /FC switch to modify the /DB switch so that it refers to >the creation date and not the last modified date. I do not know what >would happen if I also use the /FW switch to modify another /DB#40 >switch. I understand from other bulletins that the order of switches >usually does not matter. > >Can I just say: > >XXCOPY E:\Asivasrv\ /S/HO/Q1/YY /RS /ATH /FC/DB#40 /FW/DB#40 > >-Gabe Fineman --------------------------------------------------------------------- Unfortunately, /FC and /FW are mutually exclusive switches controlling the single controllable behavior. As with other mutually exclusive groups of switches, when you specify two or more of switches in the same group, then, the switch which is evaluated last (specified at the rightmost position) will prevail, cancelling the earlier setting. SO, in your example, the /FW switch comes last which cancels the earlier /FC switch and the effect will be on both /DB#40 (the left hand side /DB#40 is cancelled by /DB#40 --- albeit identical in the case). Then, how can we handle the case in your question? Then answer is, there is no way to do this in one XXCOPY command. It needs a batch file script using other techniques which may look ugly. One that comes to my mind is to make a temporary reference directory where you add entries for the selected files using one filtering operation (in your example Step 1 and 2 which can be combined into one XXCOPY operation), and modify the list of files in the reference directory using Step 3 as an additional stage. In the third stage, you will use the list of files in the reference directory to work on the real destination. In the 4th and final stage, clean up the temporary directory. Let me give you this sequence in a batch file. (I have added Step 0 in the 1st line) CLEANUP.BAT ------------------------------------------------------------- xxcopy e:\xxtmp\ /rsy/h/r/yy/ed // clean up 1st xxcopy e:\asivasrv\ e:\xxtmp\ /s/h/fc/db#40/sz0 xxcopy e:\xxtmp\ /s/h/fw/da#39/rsy/pd0 xxcopy e:\asivasrv\ e:\xxtmp\ /s/h/rsy/pd0/u xxcopy e:\xxtmp\ /rsy/h/r/yy/ed // destroy this ------------------------------------------------------------- Step 1 (2nd line) uses /FC/DB#40 to select the file using the "creation date" and selects old files with age 40 or more days and copies these qualified files into the temporary directory. Since the temporary directory does not need the actual file contents (and we are not using the filesize in selection), /SZ0 was added to create zero-length files there. Step 2 (3rd line) removes files that are 39 days or younger in the temporary directory. ----------------------------------------------------------- Note that in Step 1, we used the "File-creation" time (/FC) which is the creation date of the file in that directory which is different from the way the file age is treated in Step 2. /FW in Step 2 uses the more traditional, "Last- written" file date. ------------------------------------------------------------ You may further eliminate more files using other criteria. /RSY/PD0 will delete the selected files in the directory without extra prompts. Once you are satisfied with what's left in the reference directory (I suggest while you are debugging this, you should stop at the end of third line), you can proceed with the 4th line which does the actual deletion in the target directory. Step 3 (4th line) uses /U in conjunction with the reference directory which selects all the files in the target directory (e:\asivasrv\) which are also present in the temporary directory. Again, /RSY/PD0 does the removal job for real. Step 4 (5th line) removes the temporary directory. ------------------------------------------------------ Gabe's original command line had both /H0 and /ATH. /ATH is synonymous to /H. Therefore /H0/ATH is the same as /H0/H which can be specified simply by /H. The /AT switch was added as a generalized scheme to handle any combination of attribute-based file selection. If the H-bit (hidden attribute) is the only concern here, /H is simpler and quite intuitive as well. ------------------------------------------------------ One nice thing about the recent (beta) versions of XXCOPY is that you may leave the "comment" field even in the batch file (the string starting at //). Although the batch file itself does not strip the comment field, the XXCOPY does recognize the double-slash sequence as the beginning of a comment filed, it works to your advantage. To be consistent within your batch file, you may use the alternate prefix for the comment (double-colon, ::). CLEANUP2.BAT ------------------------------------------------------------- @echo off :: my comment which is recognized by batch file xxcopy /ec e:\xxtmp\ /rsy/h/r/yy/ed :: clean up 1st xxcopy /ce e:\asivasrv\ e:\xxtmp\ /s/h/fc/db#40/sz0 xxcopy /ce e:\xxtmp\ /s/h/fw/da#39/rsy/pd0 :: here goes the real file-delete stage xxcopy /ce e:\asivasrv\ e:\xxtmp\ /s/h/rsy/pd0/u xxcopy /ce e:\xxtmp\ /rsy/h/r/yy/ed :: destroy this ------------------------------------------------------------- The /EC (only for the first XXCOPY line in a batch file) and /CE (in the remaining lines) switches makes the batch file handles the fatal errors gracefully. That is, when something abnormal happens earlier in the step, the subsequent XXCOPY steps will not be executed (to be precise, XXCOPY will be executed but will do nothing). More on this subject in XXTB #19 http://www.xxcopy.com/xxcopy/xxcopy19.htm ------------------------ I believe this message should be an article in XXCOPY technical bulletin. So, if you have problem following this article, please give me a feedback so that it can be polished before its publication in the Tech Bulletin section. TIA. Kan Yabumoto ================================================================ Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ ------_=_NextPart_001_01C0FAA5.68641070 Content-Type: text/html Content-Transfer-Encoding: quoted-printable RE: [xxcopy] Multi-step XXCOPY operations Thank you for the excellent and detailed reply. Everythin= g seems to work fine, with one puzzling exception. The command xxcopy /ce e:\asivasrv\ e:\xxtmp\ /s/h/= rsy/pd0/u results in lines like the following as output for every d= irectory: E:\ASIVASRV\D$ RmDir failed The directories are not deleted, so no harm is done, but = I am not sure why it is trying to delete them since they are not hidden. Pe= rhaps we should have used /ATH instead of /H, since the two may be synonymo= us but still not be identical. The /H switch, as you explained in Bulletin = #4 is best thought of as "/H does not exclude hidden/system files"= ; while the /ATH switch "selects ... files by the file attributes"= ; (Bulletin #27). Perhaps it is just semantics. I vaguely remember using a shareware program called Roboc= opy decades ago to do backup in DOS and struggling mightily with its array = of confusing switches and only sporadic bulletin board support. Not only is= xxcopy clear and logical but it is well documented and has the best suppor= t (Kan) around. -Gabe Fineman -----Original Message----- From: Kan Yabumoto [mailto:tech.xxcopy@d...] Sent: Thursday, June 21, 2001 12:00 PM To: xxcopy@yahoogroups.com Subject: [xxcopy] Multi-step XXCOPY operations This message is a response to Gabe Fineman's excellent qu= estion on how to handle a complicated file-selection job which XXC= OPY cannot handle. But, a multiple-step (batch file) solution= is presented which can be applied to many other cases where XXCOPY ca= nnot process certain combination of file-selection in one ste= p. Here's Gabe's original question: >I have read Bulletin 17 on selecting files by date an= d still have a >question. I would like to delete files that meet thr= ee conditions > >1. They are marked as hidden >2. They were created more than 40 days ago (copied t= o this directory) >3. They have not been modified within the last 40 da= ys > >I meet the first two conditions with the following c= ommand > >XXCOPY E:\Asivasrv\ /S/HO/Q1/YY /RS /ATH /FC/D= B#40 > >I used the /FC switch to modify the /DB switch so th= at it refers to >the creation date and not the last modified date.&nb= sp; I do not know what >would happen if I also use the /FW switch to modify = another /DB#40 >switch. I understand from other bulletins that the o= rder of switches >usually does not matter. > >Can I just say: > >XXCOPY E:\Asivasrv\ /S/HO/Q1/YY /RS /ATH /FC/D= B#40 /FW/DB#40 > >-Gabe Fineman ---------------------------------------------------------= ------------ Unfortunately, /FC and /FW are mutually exclusive switche= s controlling the single controllable behavior. As with other mu= tually exclusive groups of switches, when you specify two or more of swit= ches in the same group, then, the switch which is evaluated last (sp= ecified at the rightmost position) will prevail, cancelling the earlier= setting. SO, in your example, the /FW switch comes last which can= cels the earlier /FC switch and the effect will be on both /DB#40= (the left hand side /DB#40 is cancelled by /DB#40 --- albeit ident= ical in the case). Then, how can we handle the case in your question? Then answer is, there is no way to do this in one XXCOPY = command. It needs a batch file script using other techniques whic= h may look ugly. One that comes to my mind is to make a tempo= rary reference directory where you add entries for the selected files u= sing one filtering operation (in your example Step 1 and 2 which = can be combined into one XXCOPY operation), and modify the list= of files in the reference directory using Step 3 as an additional= stage. In the third stage, you will use the list of files in th= e reference directory to work on the real destination. In the = 4th and final stage, clean up the temporary directory. Let me gi= ve you this sequence in a batch file. (I have added Step 0 in the 1s= t line) CLEANUP.BAT -------------------------------------------= ------------------ xxcopy e:\xxtmp\ &nb= sp; /rsy/h/r/yy/ed // clean= up 1st xxcopy e:\asivasrv\ e:\xxtmp\ /= s/h/fc/db#40/sz0 xxcopy e:\xxtmp\ &nb= sp; /s/h/fw/da#= 39/rsy/pd0 xxcopy e:\asivasrv\ e:\xxtmp\ /= s/h/rsy/pd0/u xxcopy e:\xxtmp\ &nb= sp; /rsy/h/r/yy/ed // destroy thi= s -------------------------------------------= ------------------ Step 1 (2nd line) uses /FC/DB#40 to select the file using= the "creation date" and selects old files with age= 40 or more days and copies these qualified files into the temporary dire= ctory. Since the temporary directory does not need the actual f= ile contents (and we are not using the filesize in selection= ), /SZ0 was added to create zero-length files there. Step 2 (3rd line) removes files that are 39 days or young= er in the temporary directory. --------------------------------------= --------------------- Note that in Step 1, we used the &quo= t;File-creation" time (/FC) which is the creation date of the fil= e in that directory which is different from the way the f= ile age is treated in Step 2. /FW in Step 2 uses the = more traditional, "Last- written" file date. -------------------------------------------= ----------------- You may further eliminate more files using other criteria= . /RSY/PD0 will delete the selected files in the directory= without extra prompts. Once you are satisfied with what's left in the reference<= /FONT> directory (I suggest while you are debugging this, you s= hould stop at the end of third line), you can proceed with the= 4th line which does the actual deletion in the target direct= ory. Step 3 (4th line) uses /U in conjunction with the referen= ce directory which selects all the files in the target dire= ctory (e:\asivasrv\) which are also present in the temporary d= irectory. Again, /RSY/PD0 does the removal job for real. Step 4 (5th line) removes the temporary directory. --------------------------------------= ---------------- Gabe's original command line ha= d both /H0 and /ATH. /ATH is synonymous to /H. = Therefore /H0/ATH is the same as /H0/H which can b= e specified simply by /H. The /AT switch was added as a g= eneralized scheme to handle any combination of attri= bute-based file selection. If the H-bit (hidden attribute)= is the only concern here, /H is simpler and quite i= ntuitive as well. -------------------------------------= ----------------- One nice thing about the recent (beta) versions of XXCOPY= is that you may leave the "comment" field even= in the batch file (the string starting at //). Although t= he batch file itself does not strip the comment field, the XXCOPY does recognize the double-slash sequence as t= he beginning of a comment filed, it works to your advantage= . To be consistent within your batch file, you may use the= alternate prefix for the comment (double-colon, ::). CLEANUP2.BAT -------------------------------------------------= ------------ @echo off :: my comment which is recognized by = batch file xxcopy /ec e:\xxtmp\  = ; /rsy/h/r/yy/ed :: clean up 1st xxcopy /ce e:\asivasrv\ e:\xxtmp\&nbs= p; /s/h/fc/db#40/sz0 xxcopy /ce e:\xxtmp\  = ; /s/h/fw= /da#39/rsy/pd0 :: here goes the real file-delete sta= ge xxcopy /ce e:\asivasrv\ e:\xxtmp\&nbs= p; /s/h/rsy/pd0/u xxcopy /ce e:\xxtmp\  = ; /rsy/h/r/yy/ed :: destroy this -------------------------------------------= ------------------ The /EC (only for the first XXCOPY line in a batch file) = and /CE (in the remaining lines) switches makes the batch fi= le handles the fatal errors gracefully. That is, when= something abnormal happens earlier in the step, the subsequent XXC= OPY steps will not be executed (to be precise, XXCOPY = will be executed but will do nothing). More on this subjec= t in XXTB #19 http://www.xxcopy.com/xxcopy/xxcopy19.htm= FONT> ------------------------ I believe this message should be an article in XXCOPY tec= hnical bulletin. So, if you have problem following this a= rticle, please give me a feedback so that it can be polished bef= ore its publication in the Tech Bulletin section. TIA.= Kan Yabumoto =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/t= erms/ ------_=_NextPart_001_01C0FAA5.68641070--
This message if part of XXCOPY's message Archive. The archive contains all the messages posted at Yahoo!Groups: XXCOPY.