temp 发表于 2010-2-21 13:13

[请教]批处理如何查找最新的文件夹名称并自动复制到指定文件夹中

本帖最后由 ssqj111 于 2012-6-18 11:32 编辑

if not exist "E:\NETT_Slof\Symantec Antivirus企业版9.0\VirusDefs" md "E:\NETT_Slof\Symantec Antivirus企业版9.0\VirusDefs"
set newdest=E:\NETT_Slof\Symantec Antivirus企业版9.0\VirusDefs
copy "C:\Program Files\Common Files\Symantec Shared\VirusDefs\20100201.009" "%newdest%\"20100201.009是文件夹名

今天最新的文件夹名称是: 20100219.002

下一次文件夹名称不详


谢谢!

可供参考的是
在C:\Program Files\Common Files\Symantec Shared\VirusDefs中有两个文件中包含最新的文件夹名
definfo.dat

CurDefs=20100219.002
LastDefs=20100201.009

usage.dat
[20100219.002]
DEFWATCH_10=1
NAVCORP_70=1
NAVCORP_70_2=1




temp 发表于 2010-2-24 22:35

已得到高人的解决方案@echo off
setlocal enabledelayedexpansion
for /f "tokens=1,2 delims==" %%i in (definfo.dat) do (
   if /i "%%i"=="curdefs" set str=%%j
)
xcopy /e /y "%~dp0%str%" "E:\NETT_Slof\Symantec Antivirus企业版9.0\VirusDefs\%str%\"
pause >nul

temp 发表于 2010-2-24 22:39

在高高人的耐心指导下,获得如下解决方案@echo off
echo @echo off>"%CommonProgramFiles%\Symantec Shared\VirusDefs\back.cmd"
echo setlocal enabledelayedexpansion>>"%CommonProgramFiles%\Symantec Shared\VirusDefs\back.cmd"
echo for /f "tokens=1,2 delims==" %%%%i in (definfo.dat) do (>>"%CommonProgramFiles%\Symantec Shared\VirusDefs\back.cmd"
echo if /i "%%%%i"=="curdefs" set str=%%%%j>>"%CommonProgramFiles%\Symantec Shared\VirusDefs\back.cmd"
echo )>>"%CommonProgramFiles%\Symantec Shared\VirusDefs\back.cmd"
echo xcopy /e /y "%%~dp0%%str%%" "E:\NETT_Slof\Symantec Antivirus企业版9.0\VirusDefs\%%str%%\">>"%CommonProgramFiles%\Symantec Shared\VirusDefs\back.cmd"
call "%CommonProgramFiles%\Symantec Shared\VirusDefs\back.cmd"

temp 发表于 2010-2-24 22:42

唯一还没解决的是均无法调用:em07:call "%CommonProgramFiles%\Symantec Shared\VirusDefs\back.cmd"[/start "" "%CommonProgramFiles%\Symantec Shared\VirusDefs\back.cmd
页: [1]
查看完整版本: [请教]批处理如何查找最新的文件夹名称并自动复制到指定文件夹中