<!--#include file="inc/config.asp"--><%
dim rootDirPath,toDirPath,nRootDirLen,nForDirCount
rootDirPath=handlePath("/")
toDirPath=handlePath("F:\backWeb\" & format_Time(now(),5) )
nRootDirLen=len(rootDirPath)
nForDirCount=3 '循环目录总数'
call createDirFolder(toDirPath) '创建目标文件夹'
call echo("源目录",rootDirPath)
call echo("源目录长度",nRootDirLen)
call echo("到目录",toDirPath)
call hr()
call latestFiles(rootDirPath)
'最新文件'
function latestFiles(dirPath)
dim content,fileEditTime,fileName,filePath,splstr,nDay,toFilePath,toFEditTime,nMiao,folderName,folderPath,newDirPath
dim isOK,fileExt
if right(dirPath,1)="\" then
dirPath=mid(dirPath,1,len(dirPath)-1)
' call eerr("dirPath",dirPath)
end if
call echoYellow("文件夹",dirPath)
'*********** 处理文件 ***********'
content=getDirFileNameList(dirPath,"*")
splstr=split(content,vbcrlf)
for each fileName in splstr
isOK=false
filePath=dirPath & "\" & fileName
'文件夹不为空'
if fileName<>"" and left(fileName,1)<>"#" then
fileExt=getFileAttr(filePath,4)
if instr("|rar|zip|mdb|", "|"& fileExt & "|")=false then
isOK=true
end if
' call echo("fileExt文件后缀",fileExt)
end if
'为真则处理文件'
if isOK then
fileEditTime=getFileEditDate(filePath)
nDay=dateDiff("d", fileEditTime, now())
if nDay=0 then
call echoRed(filePath,fileEditTime & " - "& nDay &"天")
newDirPath=toDirPath & "\" & mid(dirPath,nRootDirLen+1)
call createDirFolder(newDirPath) '创建目标文件夹'
toFilePath=newDirPath & "\" & fileName
'目录文件不存在'
if checkFile(toFilePath)=false then
call echo("复制文件",toFilePath)
call copyFile(filePath,toFilePath) '复制文件'
else
toFEditTime=getFileEditDate(toFilePath)
call echoBlue(toFilePath,toFEditTime & " - "& nDay &"天")
nMiao=dateDiff("s", toFEditTime,fileEditTime)
if nMiao>0 then
call echo("相差", nMiao & "秒")
call echo("删除文件,并复制新文件",toFilePath)
call deleteFile(toFilePath)
call copyFile(filePath,toFilePath) '复制文件'
end if
end if
end if
end if
next
call hr()
' call echo("文件名列表",content)
'*********** 处理目录 ***********'
content=getDirFolderNameList(dirPath)
splstr=split(content,vbcrlf)
for each folderName in splstr
isOK=false
folderPath = dirPath & "\" & folderName
if folderName<>"" and left(folderName,1)<>"#" then
if instr("|data|404|", "|"& lcase(folderName) & "|")=false then
isOK=true
end if
end if
if isOK then
' call echo("folderName",folderName)
nForDirCount=nForDirCount-1 '每减一'
if nForDirCount>0 then
call echo("循环目录子文件夹 " & nForDirCount,folderPath)
call latestFiles(folderPath)
end if
end if
next
' call echo("文件夹列表",content)
end function
%>