建立一个当前date 命名的文件夹,copy文件到此文件夹中,并记录log

@echo off REM auther:hpf REM This version is only for windows REM Pls set the src and dest before use the script set src=D:/src.txt set dest=D:/swd/ set log=D:/swd/log.txt REM create the dir by date reg add "HKEY_CURRENT_USER/Control Panel/International" /v sShortDate /t REG_SZ /d yyyy-M-d /f set "Week=Mon Tue Wed Thu Fri Sat Sun 星期一 星期二 星期三 星期四 星期五 星期六 星期日" set datestr=%date% for %%n in (%Week%) do call set "datestr=%%datestr:%%n=%%" md %dest%%datestr% echo start download ,pls wait ,,,,,,, echo -------------------------------------------->>%log% echo %date% %time% start download >>%log% copy %src% %dest%%datestr% if errorlevel 0 echo %date% %time% download success>>%log% if errorlevel 1 echo %date% %time% download faild >>%log% pause 

 

 

PS:写此批处理脚本的一点小心得

 

1.查看命令详细帮助  

   help 显示所有命令

   命令 /?  显示该命令的详细使用方式 ,e.g :  dir /?

2.字符串的替换

   %PATH:str1=str2%   PATH 中,所有str1 都被替换成str2

3.字符串截取

 %PATH:~10,5%   从第11个数开始,截取5个 

  %PATH:~-10%     截取最后10个字符

  %PATH:~0,-2%    截取全部字符,除了最后两个

  %date:~,2%        截取前两个字符  

 

 

 

 

 

一些问题:

 

set   date=%2011%

md   D:/test/%date%                        成功

md   D:/%date%/test.txt                   失败  

 

不知道什么原因~真是奇怪

 

 

 

reference


http://blog.csdn.net/gltianwen/archive/2009/09/07/4527420.aspx

http://hi.baidu.com/holypku/blog/item/422311255fc4cb6735a80fbf.html

http://bbs.bathome.net/thread-3328-1-1.html

http://hi.baidu.com/etnet/blog/item/9c4c2e30976a7a9da9018eac.html

 

 

你可能感兴趣的:(c,Date,脚本,sun,Path,download)