[BAT] 以当前时间为名创建文件夹,将本地文件夹里的文件拷贝到远程共享目录

@echo off



set sourcePath=D:\DOAutomationTest\automation_do_ma_soapui\TestResult\PA

set targetPath=\\szotwin2k801\AutomationReport\PA



set directoryName=%date:~6,-4%-%date:~0,2%-%date:~3,2%-%time::=-%

echo I will create a directory : +%directoryName%



if exist %targetPath%\%directoryName% (echo y|cacls %targetPath%\%directoryName% /p everyone:f >nul 2>nul &&rd /s /q %targetPath%\



%directoryName%) else echo directory doesn't exist,create it



md %targetPath%\%directoryName%

xcopy /d %sourcePath% %targetPath%\%directoryName%



rem delete reports generated 7 days ago

forfiles /p %targetPath% /s /m *.* /d -7 /c "cmd /c del /f @path">nul 2>nul

for /f "tokens=*" %%a in ('dir /b /ad /s^|sort /r') do rd "%%a" 2>nul



exit

  文件夹名为 : 2015-07-28-10-34-04.09

你可能感兴趣的:(当前时间)