path_list=GetAllPath('D:\DJJS\')
*CREATE CURSOR (lcTblDir) (fldsn I(3),flddir C(200))
*删除dsdf目录下文件名中有20170518日期的文件
SELECT (path_list)
SCAN
path_tmp=ADDBS(ALLTRIM(flddir))
FOR I=1 TO ADIR(FILE_LIST,path_tmp+'*.DBF')
IF RIGHT(JUSTSTEM(FILE_LIST[I,1]),8)='20170518'
DELETE FILE (path_tmp+FILE_LIST[I,1])
ENDIF
ENDFOR
RELEASE FILE_LIST
ENDSCAN
USE IN (path_list)
*把不同文件夹下的文件,放在同一个文件夹中且只放文件
path2_tmp='d:\temp\'
path_list=GetAllPath('D:\DJJS\')
SELECT (path_list)
SCAN
path_tmp=ADDBS(ALLTRIM(flddir))
FOR I=1 TO ADIR(FILE_LIST,path_tmp+'*.DBF')
COPY FILE (path_tmp+FILE_LIST[I,1]) TO (path2_tmp+FILE_LIST[I,1])
ENDFOR
RELEASE FILE_LIST
ENDSCAN
USE IN (path_list)
RETURN
FUNCTION GetAllPath (tcRoot)
IF EMPTY(tcRoot) OR
NOT DIRECTORY(tcRoot)
RETURN '目录不正确'
ENDIF
tcRoot=ADDBS(ALLTRIM(tcRoot))
LOCAL ARRAY laDirs[1]
LOCAL i, n,lcTblDir, lcDir, lnCount,lcTblDir2
lcTblDir= SYS(2015)
CREATE CURSOR (lcTblDir) (fldsn I(3),flddir C(200))
INSERT INTO (lcTblDir) (fldsn,flddir) VALUES (0,tcRoot)
i = 0
DO WHILE .T.
lcTblDir2= SYS(2015)
SELECT * FROM (lcTblDir) WHERE fldSn=i INTO CURSOR (lcTblDir2)
IF RECCOUNT(lcTblDir2)=0
USE IN (lcTblDir2)
EXIT
ENDIF
SELECT (lcTblDir2)
SCAN
lcDir = ALLTRIM(flddir)
lnCount = ADIR(laDirs,lcDir + "*.", "D")
FOR n = 1 TO lnCount
IF !("." $ laDirs(n,1) OR ".." $ laDirs(n,1))
INSERT INTO (lcTblDir) (fldsn,flddir) VALUES (i+1,lcDir+ADDBS(laDirs(n,1)))
ENDIF
ENDFOR
ENDSCAN
USE IN (lcTblDir2)
i=i+1
ENDDO
SELECT (lcTblDir)
RETURN lcTblDir
ENDFUNC