Board logo

标题: 会写批处理稳健的高手帮个忙。 [打印本页]

作者: 稳健     时间: 2004-6-9 00:00    标题: 会写批处理稳健的高手帮个忙。

因为工作需要,需要每天对一些文件进行备份,想做一个 批处理进行备份。做成以后不能达到自己所需要的目的。又无法 。只好想高手求救。

要求:备份一个文件下所有文件到 另一个文件夹,并使 每次备份存放的文件 夹都以当天时期命名。
做一个批处理文件,希望高手指点 !!!

作者: guiping     时间: 2004-6-16 00:00
同样的问题,顶一下。
作者: 千千情结     时间: 2004-6-17 00:00
路过!!
不会!1
作者: cn_archer     时间: 2004-6-18 00:00
如果你是用Windows操作系统,那还是用WinRAR之类的软件更好吧。
在DOS下用日期做目录似乎就有点不太好吧。

作者: o2y     时间: 2004-6-19 00:00
偶曾经有个每天只运行一次的批处理程序,把其中的动作替换一下就是你要的功能了……

不过,不知找不找的到——DOS毕竟多年少用了^_^
作者: o2y     时间: 2004-6-19 00:00
找不到了……

说说主要原理吧:
1、每天生成一个c:\date.new文件;在autoexec。bat中:
echo.|date|find "Current" >date.new

2、如果不存在c:\date.old则改名为date.old然后调用你的动作批文件,
存在则:fc date.new date.old 根据结果相同与否进行处理即可。



作者: jzhupo     时间: 2004-7-16 00:00
我有一个get.exe程序
使用方法如下
GET Version 2.4   -   BATch File Enhancer   -   Copyright 1991 Bob Stephan
  Syntax:  GET command argument(s) /switches     More Instructions: GET.DOC
Purpose             Command   Argument(s)   Environment  ErrorLevel  Extended
---------           -------   -----------   --(GET=)---  --(Exit)--  --[E]---
          --------- String Handling and Screen I/O Commands --------
Get character(InKey)C[E] ["prompt"][chars]   Character   ASCII code  No Echo
Get yes/no aNswer   N[E] ["prompt"][seconds] Character   ASCII code  No Echo
Get string          S[E] ["prompt"][pattern] String      Length      No Echo
Put string (Zap)    Z[E] ["string/prompt"]   String      Length      StdInput
Moving Text(GetaKey)T[E] "filespec" [chars]  Character   ASCII code  No Echo
Key check (IsKey)   I[E] ["prompt"]          Char.Waitng Char.Waitng Get Char
Date and Time       H[E] 1=DoW 2=DoM 4=Mon 8=Yr 16=Hr 32=Min 64=Sec  Sum/Cat
Keyboard BUffer     U[E] ["chars"][num][/Wnum]  --       Length      Caps/Num
'Rithmetic (add)    R[E]  [num] [/Wnum]      Sum/Diff    Sum/Diff    Subtract
Clear (Blank) Screen  B[E] [New attribute]      Old attribute        HexAttr
Video mode/VGA border V[E] [New mode/color]     Old mode/color       VGA Border
          --------- Disk and File Commands --------
Get file size (DIR=0)  F[E] filespec[/Wdiv/X]Bytes/Hex   Kilobytes   Kb/10
Get disk free space    K[E] [drive] [/Wdiv]  Kilobytes   Kb/10       Kb/100
Get disk capacity      Q[E] [drive] [/Wdiv]  Kilobytes   Kb/10       Kb/100
Get volume label       L[E] ["label"][drive] Label       1=yes,0=no  Match
Get current directory  Y[E] [drive for Y]    Directory   Level/Drive Drive:A=0
          --------- Memory and System Commands --------
Get Environment left   E[E]                  Bytes left  Bytes left  Bytes/10
Get memory free        M[E]                  Kilobytes   Kilobytes   Kb/10
Get/Set Break Flag     BR   [New flag 1=on, 0=off]   Old flag        None
Check for printer(PRN) P[E]                  1=yes,0=no  1=yes,0=no  Initialize
Check 4DOS/Windows     4[E]                  1=yes,0=no  1=yes,0=no  Windows
Get DOS version        D[E]                  Major Vers. MajorMinor  MinorEnv
Check coprocessor/CPU  7[E]                  1=yes,0=no  1=yes,0=no  CPU Type
Check ANSI.SYS/Model   A[E]                  1=yes,0=no  1=yes,0=no  PC Model
Warm/Cold Boot         W[E] If argument given then 1=warm, 0=cold    ColdBoot
Surrogates: }=Carriage Return, ~=Escape, Alt-255=Space/Blank.
SWITCHES: /C Ctrl-Break, /U /L case, /M Master Env, /E Enhanced keys, /Vvar=
  /X eXtended keys/Hex, /A[nnn] prompt Attribute, /W[nnnn] Wait seconds/div
  /B flush key Buffer, /TL /TR Trim, /~ Escape action for GET S, /V- No var
See GET.DOC for additional features and BATch programming instructions.
作者: 中华之子     时间: 2004-7-17 00:00
这么长有没有简单实用的呀
作者: dsfp     时间: 2004-7-28 00:00
可用 date 和 for 结合使用来达到目的,范例如下,按你的实际情况稍作修改即可。 if exist c:\date.txt del c:\date.txt
date /t >>c:\date.txt ::提取当前系统日期到txt文件中备用
if not exist c:\backup md c:\backup ::建立备份存放目录,假定为C盘
for /f %%a in (c:\date.txt) do if not exist c:\backup\%%a md c:\backup\%%a ::建立以日期命名的子目录
for /f %%a in (c:\date.txt) do copy x:\xx\*.* c:\backup\%%a ::备份文件
del c:\date.txt ::清理临时文件