如何用存档文件名中的当前日期创建RAR存档? [英] How to create a RAR archive with current date in archive file name?

查看:189
本文介绍了如何用存档文件名中的当前日期创建RAR存档?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的文件夹D:\data中包含许多子文件夹和文件,并且我希望将此文件夹及其批处理文件存档到指定目录,并在存档文件名中添加当前日期,例如F:\11.08.2016_data.

I have folder D:\data with lots of subfolders and files and I want to archive this folder with a batch file to a specified directory with current date added in archive file name, e.g. F:\11.08.2016_data.

我的命令行到目前为止:

My command line is so far:

"C:\Program Files\WinRAR\rar.exe" a -ep1 -r "data" "D:\data"

此命令行在文件夹My Documents中创建RAR存档文件data.rar.

This command line creates RAR archive file data.rar in folder My Documents.

如何添加日期和更改归档目录?

How can I add date and change the archiving directory?

推荐答案

如何构建 WinRAR 命令行?

How to build a WinRAR command line?

  1. 启动 WinRAR .
  2. 帮助主题上单击菜单帮助.
  3. 单击列表项命令行模式中的选项卡内容.
  4. 单击列表项命令行语法,阅读此帮助页面,然后将粗体行复制到文本编辑器或命令提示符窗口中.
  5. 单击列表项命令中的选项卡内容.
  6. 单击列表项字母命令列表,并在文本编辑器或命令提示符窗口中将<command>替换为最适合该任务的命令字母.
  7. 点击列表项 Switchs 中的 Contents 标签.
  8. 单击列表项字母开关列表,然后用对任务有用的那些开关替换文本编辑器或命令提示符窗口中的-<switch1> -<switchN>.
  9. 用适当的文件和/或文件夹名称替换文本编辑器或命令提示符窗口中的 WinRAR 命令行的其余部分.
  1. Start WinRAR.
  2. Click in menu Help on Help topics.
  3. Click on tab Contents on list item Command line mode.
  4. Click on list item Command line syntax, read this help page and copy the bold line into a text editor or into a command prompt window.
  5. Click on tab Contents on list item Commands.
  6. Click on list item Alphabetic commands list and replace <command> in text editor or command prompt window by most suitable command letter for the task.
  7. Click on tab Contents on list item Switches.
  8. Click on list item Alphabetic switches list and replace -<switch1> -<switchN> in text editor or command prompt window by those switches which are useful for the task.
  9. Replace the rest of the WinRAR command line in text editor or command prompt window by the appropriate file and/or folder names.

如何构建 RAR 命令行?

How to build a RAR command line?

  1. 打开包含 WinRAR 程序文件的文件夹.
    标准文件夹为:
    %ProgramFiles%\WinRAR
    %ProgramFiles(x86)%\WinRAR
  2. 双击文件Rar.txt将其打开.这是Rar.exe的手册,这是 WinRAR 的控制台版本.
  3. RAR命令行语法一章中,介绍了常规命令行语法,应将其用作在文本编辑器或命令提示窗口中输入命令的模板.
  4. 接下来,将按字母顺序列出可用命令,并简要说明.这些命令之一必须用于 Rar 命令行.
  5. 然后按照字母顺序排列并说明了开关列表.建议先阅读有关这些开关的信息,并在文本编辑器或命令提示符窗口中阅读有关该任务的有用开关.
  6. 在文本编辑器或命令提示符窗口中键入 Rar 命令行的其余部分,即文件名和文件夹名.
  1. Open the folder containing the program files of WinRAR.
    The standard folders are:
    %ProgramFiles%\WinRAR
    %ProgramFiles(x86)%\WinRAR
  2. Double click on the file Rar.txt to open it. This is the manual for Rar.exe, the console version of WinRAR.
  3. In chapter RAR command line syntax the general command line syntax is described which should be used as template for the command to enter in a text editor or in a command prompt window.
  4. Next the available commands are listed in alphabetical order with a brief description. One of these commands must be used for the Rar command line.
  5. Then the list of switches follows, also in alphabetical order and also explained. It is advisable to read about the switches and while reading typing the useful switches for the task in text editor or in command prompt window.
  6. Type the rest of the Rar command line in text editor or command prompt window, i.e. the file and folder names.

适合您的任务的 Rar 命令行为:

An appropriate Rar command line for your task would be:

"%ProgramFiles%\WinRAR\rar.exe" a -agYYYY-MM-DD -cfg- -ep1 -inul -m5 -r -y "F:\data_.rar" "D:\data\"

开关-agYYYY-MM-DD负责在目录F:\中创建归档文件,例如名称为data_2016-08-11.rar的文件.

The switch -agYYYY-MM-DD is responsible for creating in directory F:\ archive files for example with name data_2016-08-11.rar.

当然也可以使用:

"%ProgramFiles%\WinRAR\rar.exe" a -agDD.MM.YYYY -cfg- -ep1 -inul -m5 -r -y "F:\data_.rar" "D:\data\"

此命令行在名称为data_11.08.2016.rarF:\归档文件中创建.但这是不可取的,因为国际日期格式YYYY-MM-DD具有以下优点:按名称按字母顺序列出的文件也会自动按日期列出,而日期格式DD.MM.YYYY则不是这种情况.

This command line creates in F:\ archive files with name data_11.08.2016.rar. But this is not advisable as the international date format YYYY-MM-DD has the advantage that the files listed alphabetically sorted by name are automatically also listed by date which is not the case with date format DD.MM.YYYY.

查看上的答案是否仅使用WinRAR命令行批量压缩1个文件夹?,以了解指定的区别D:\data Rar 命令行上的D:\data\.

See the answer on Simply compress 1 folder in batch with WinRAR command line? for difference on being specified D:\data or D:\data\ on Rar command line.

必须在-ag和日期格式字符串之间插入+,以保留到data的日期,并在存档文件名中用下划线分隔.

A + must be inserted between -ag and date format string for date left to data separated with an underscore in archive file name.

RAR文件名开头的国际格式日期YYYY-MM-DD:

Date in international format YYYY-MM-DD at beginning of RAR file name:

"%ProgramFiles%\WinRAR\rar.exe" a -ag+YYYY-MM-DD -cfg- -ep1 -inul -m5 -r -y "F:\_data.rar" "D:\data\"

RAR文件名开头的格式为DD.MM.YYYY的日期:

Date in format DD.MM.YYYY at beginning of RAR file name:

"%ProgramFiles%\WinRAR\rar.exe" a -ag+DD.MM.YYYY -cfg- -ep1 -inul -m5 -r -y "F:\_data.rar" "D:\data\"

这篇关于如何用存档文件名中的当前日期创建RAR存档?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆