WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Directory and Deltree UDFs

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

XCopy Archive Files Only

 Keywords:  XCOPY Archive Attribute Only

#DefineFunction UDFXcopyArchive(fromdir,todir)
    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")
    
    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,"\")
    
    ;Make sure target directory exists
    If DirExist(todir)==@FALSE Then DirMake(todir)
    
    ;copy files in this directory
    filelist=FileItemize("*.*")
    filecount=ItemCount(filelist,@TAB)
    For xx=1 To filecount
       thisfile=ItemExtract(xx,filelist,@TAB)
       attr=FileAttrGet(thisfile)
       If StrIndex(attr,"A",0,@FWDSCAN)==0 Then Continue
       FileCopy( thisfile , StrCat(todir,"*.*") , 0)
       FileAttrSet(thisfile,"a")
    Next
    
    ;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,"\")
       UDFXcopyArchive(fullfromdir,fulltodir)
    Next
    Return
#EndFunction


UDFXcopyArchive("C:\temp","c:\tempx")
Message("","Xcopy complete")


Article ID:   W15748
File Created: 2003:05:28:10:24:34
Last Updated: 2003:05:28:10:24:34