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

查看:18
本文介绍了如何在存档文件名中创建具有当前日期的 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.

我的命令行到此为止:

"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. 点击列表项字母命令列表并用最适合任务的命令字母替换文本编辑器或命令提示符窗口中的.
  7. 点击列表项开关上的标签内容.
  8. 点击列表项字母开关列表并替换-<switch1>- 在文本编辑器或命令提示符窗口中,通过对任务有用的那些开关.
  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\"

此命令行在 F:\ 中创建名为 data_11.08.2016.rar 的存档文件.但这不是可取的,因为国际日期格式 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个文件夹?上看到答案吗?指定的区别Rar 命令行中的 D:\dataD:\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.

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

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\"

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

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天全站免登陆