一个文件添加到每个RAR文件的文件夹中 [英] Add a single file to each rar file in a folder

查看:215
本文介绍了一个文件添加到每个RAR文件的文件夹中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图找出如何在文件夹中添加一个文件中的每个.rar文件。

例如我有:


  • rar1.rar

  • rar2.rar

  • rar3.rar

和我想要'的readme.txt'文件添加到每个人。

或者,如果这是不可能的,我可以只提取所有.rar文件把他们变成文件夹,然后使用这个批处理code到COM preSS呢?

我如何包括readme.txt文件?

  @ECHO OFF
CD C:\\用户\\ userss \\桌面\\ COM pressing
SET PATH = C:; C:\\ Program Files文件\\ WinRAR的; C:\\ WINDOWS \\ SYSTEM32; C:\\ WINDOWS; C:\\ Windows \\ System32中\\ WBEM;%PATH%
FOR / Fdelims =%% D IN('DIR / B')DO WinRAR的一个-M0 -epC:\\用户\\ userss \\桌面\\目标\\ %%〜nxd.rar%%〜FD
出口


解决方案

我建议如下:

 关闭@echo
FOR / Fdelims =%%我在('DIR / B%USERPROFILE%\\桌面\\ COM pressing \\ *。RAR')做的%ProgramFiles%\\ WinRAR的\\ RAR.EXE一-ep -idq -y -M0%USERPROFILE%\\桌面\\ COM pressing \\ %%我%USERPROFILE%\\桌面\\ COM pressing \\ README.TXT

或许有人会认为这可能是也做不带命令的 DIR 是:

 关闭@echo
为%%我在(%USERPROFILE%\\桌面\\ COM pressing \\ *。RAR)做的%ProgramFiles%\\ WinRAR的\\ RAR.EXE一-ep -idq -y -M0%%〜我%USERPROFILE%\\桌面\\ COM pressing \\ README.TXT

但是,这并不在FAT32驱动器的工作,因为命令作为修改后,再次产生无限循环处理每个RAR压缩文件。

按字母顺序排列,而FAT32文件系统驱动程序存储在文件分配表(FAT)与目录中的所有文件的修改FAT变化,由此排序顺序,返回文件列表中的NTFS文件系统驱动程序总是返回排序的文件列表。

下面的循环将避免在FAT32驱动器无限循环:

 关闭@echo
为%%我在(%USERPROFILE%\\桌面\\ COM pressing \\ *。RAR)做的%ProgramFiles%\\ WinRAR的\\ RAR.EXEU -ep -idq -y -M0%%〜我%USERPROFILE%\\桌面\\ COM pressing \\ README.TXT

所不同的是使用RAR命令 U 而不是 A 。这导致将单一文件一次到每* .rar文件。当作为通话 RAR.EXE 为已经更新存档第二次,RAR检测到该文件已经在存档并不会修改RAR压缩包一次。因此,在每次* .rar文件是由 RAR.EXE (第一个加入该​​文件,第二个不改变任何东西),在循环结束处理两次

但是,使用命令 DIR 避免处理每个RAR文件不止一次NTFS和FAT32的驱动器。

有必要使用GUI 的WinRAR.exe 而不是控制台 RAR.EXE 添加 README.TXT 来ZIP压缩文件,因为控制台版本只支持如在Program Files文件夹的文本文件 Rar.txt 的顶部解释RAR压缩文件的 WinRAR的的是手册中的控制台版本。

 关闭@echo
FOR / Fdelims =%%我在('DIR / B%USERPROFILE%\\桌面\\ COM pressing \\ *。ZIP')做的%ProgramFiles%\\ WinRAR的\\的WinRAR.exe一-ep -ibck -y -M0%USERPROFILE%\\桌面\\ COM pressing \\ %%我%USERPROFILE%\\桌面\\ COM pressing \\ README.TXT

开关 -idq 由开关代替 -ibck 运行的 WinRAR的的中背景这意味着最小化到系统托盘。有关的命令和GUI版本开关的详细信息见的的 WinRAR的的标签上的内容帮助本章的命令行模式的。的GUI版本支持的交换机列表是家用机版支持的开关列表略有不同。

I'm trying to figure out how to add a file in each .rar file in a folder.

For example I have:

  • rar1.rar
  • rar2.rar
  • rar3.rar

And I want the 'readme.txt' file added to each of them.

Or if that isn't possible I can just extract all the .rar files turning them into folder then use this batch code to compress them?

How do I include the readme.txt file?

@ECHO OFF
cd C:\Users\userss\Desktop\compressing
SET PATH=C:;C:\Program Files\WinRAR;C:\Windows\system32;C:\Windows;C:\Win dows\System32\Wbem;%PATH%
FOR /f "delims=" %%d IN ('DIR /B') DO WinRAR a -m0 -ep "C:\Users\userss\Desktop\destination\%%~nxd.rar" "%%~fd"
EXIT

解决方案

I suggest following:

@echo off
for /F "delims=" %%I in ('dir /B "%USERPROFILE%\Desktop\compressing\*.rar"') do "%ProgramFiles%\WinRAR\Rar.exe" a -ep -idq -y -m0 "%USERPROFILE%\Desktop\compressing\%%I" "%USERPROFILE%\Desktop\compressing\readme.txt"

Some might think this could be done also without command DIR using:

@echo off
for %%I in ("%USERPROFILE%\Desktop\compressing\*.rar") do "%ProgramFiles%\WinRAR\Rar.exe" a -ep -idq -y -m0 "%%~I" "%USERPROFILE%\Desktop\compressing\readme.txt"

But this does not work on FAT32 drives because command FOR processes each RAR archive after modification once more resulting in an endless loop.

The NTFS file system driver returns the list of files always sorted alphabetically while FAT32 file system driver returns the files list as stored in file allocation table (FAT) whereby sort order in FAT changes with every file modification in a directory.

The following loop would avoid an endless loop on FAT32 drives:

@echo off
for %%I in ("%USERPROFILE%\Desktop\compressing\*.rar") do "%ProgramFiles%\WinRAR\Rar.exe" u -ep -idq -y -m0 "%%~I" "%USERPROFILE%\Desktop\compressing\readme.txt"

The difference is using RAR command u instead of a. This results in adding the single file once to each *.rar file. When FOR calls Rar.exe a second time for an already updated archive, RAR detects that the file is already in the archive and does not modify the RAR archive once more. So after each *.rar file is processed twice by Rar.exe (first adding the file, second not changing anything), the FOR loop ends.

However, using command DIR avoids processing each rar file more than once on NTFS and FAT32 drives.

It is necessary to use GUI WinRAR.exe instead of console Rar.exe for adding readme.txt to ZIP archives because the console version supports only RAR archives as explained at top of text file Rar.txt in program files folder of WinRAR being the manual for the console version.

@echo off
for /F "delims=" %%I in ('dir /B "%USERPROFILE%\Desktop\compressing\*.zip"') do "%ProgramFiles%\WinRAR\WinRar.exe" a -ep -ibck -y -m0 "%USERPROFILE%\Desktop\compressing\%%I" "%USERPROFILE%\Desktop\compressing\readme.txt"

The switch -idq is replaced by switch -ibck for running WinRAR in background which means minimized to system tray. For details on commands and switches of GUI version see in help of WinRAR on tab Contents the chapter Command line mode. The list of supported switches of GUI version is slightly different to list of supported switches of console version.

这篇关于一个文件添加到每个RAR文件的文件夹中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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