Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
Keywords: XCOPY with some excludes UDFXCopyExclude
;*************************************************************************** ;** Bill Meek - 7/02/2002 ;** UDFXCopyExclude ;** build from the UDFXcopy in the tech database at ;** WinBatch/UDF - UDS Library/DelTree and Xcopy ;** ;** Purpose: Perform an xcopy excluding certain folders ;** Notes: The dirskip parameter is a list of directories ;** seperated by the delimter parameter ;** Revisions: Add code for case. Convert all to lowercase. ;*************************************************************************** #DefineFunction UDFXCopyExclude(fromdir,todir,dirskip,delimiter) Terminate(DirExist(fromdir)==@false,"Eeep","From directory does not exist") ;make sure we have a full path or a UNC fromtest=strindex(fromdir,":",0,@fwdscan) + (strsub(fromdir,1,2)=="\\") totest=strindex(todir,":",0,@fwdscan) + (strsub(todir,1,2)=="\\") Terminate(fromtest==0,"Eeep","Full path must be specified for FromDir") Terminate(totest==0,"Eeep","Full path must be specified for ToDir") dirskipcnt=ItemCount(dirskip,delimiter) For xx = 1 To dirskipcnt ;Check paths of skip list cdirskip=Itemextract(xx,dirskip,delimiter) skiptest=strindex(cdirskip,":",0,@fwdscan) + (strsub(cdirskip,1,2)=="\\") Terminate(skiptest==0,"Eeep","Full path must be specified for DirSkip list") ;convert to lower case cdirskip=StrLower(cdirskip) ;cleanup passed parameters (as below) in list If strsub(cdirskip,strlen(cdirskip),1) != "\" cdirskip = strcat(cdirskip,"\") EndIf dirskip=ItemReplace(cdirskip, xx, dirskip, delimiter) Next DirChange(fromdir) ;clean up passed paramters just in case if strsub(fromdir,strlen(fromdir),1) != "\" then fromdir=strcat(fromdir,"\") if strsub(todir,strlen(todir),1) != "\" then todir=strcat(todir,"\") if ItemLocate(StrLower(fromdir), dirskip, delimiter) == 0 ;Make sure target directory exists if DirExist(todir)==@FALSE then DirMake(todir) ;copy files in this directory FileCopy( strcat(fromdir,"*.*") , strcat(todir,"*.*") , 0) ;get list of subdirectories dirlist=DirItemize("*.*") count=ItemCount(dirlist,@tab) ;Preocess each subdirectory for xx=1 to count thisdir=ItemExtract(xx,dirlist,@tab) fulltodir=strcat(todir,thisdir,"\") fullfromdir=strcat(fromdir,thisdir,"\") UDFXcopyExclude(fullfromdir,fulltodir,dirskip,delimiter) next EndIf return #EndFunction folderstoskip = StrCat("c:\SouRce\oTHer\", @TAB, "c:\sOURCe\iN\") UDFXcopyExclude("c:\Source\", "C:\Dest\", folderstoskip, @TAB)
Article ID: W15756
File Created: 2011:01:12:09:38:24
Last Updated: 2011:01:12:09:38:24