如何从一个文件夹的子文件夹中提取所有多卷RAR压缩文件? [英] How to extract all multi-volume RAR archives from subfolders of a folder?

查看:408
本文介绍了如何从一个文件夹的子文件夹中提取所有多卷RAR压缩文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我搜索的方式通过批量下载后解压多卷档案。

I search for a way to unpack multi-volume archives after download via batch.

我下载的文件夹与.R?在它的文件通过FTP监控程序,并希望这样的 WinRAR的的推移在源文件夹中的第一个子文件夹,并开始拆包.r00,删除归档,并与解压缩文件文件夹移动到新位置。

I download folders with .r?? files in it over a FTP monitoring program and want that WinRAR goes in the first subfolder in the source folder and start unpacking .r00, delete the archive and move the folder with the unpacked files to a new location.

然后批处理脚本应与下一子文件夹重新开始这个过程。

Then the batch script should start this process again with the next subfolder.

假设源文件夹 C:\\用户\\解压包含以下与文件子文件夹:

Let's say the source folder C:\Users\unpack contains following subfolders with files:


  • 源文件夹

    • subfolder1

      • Archive1.r00

      • Archive1.r01

      • Archive1.r02

      • xxx.txt


      • Archive2.r00

      • Archive2.r01

      • yyy.txt


      • Archive3.r00

      • Archive3.r01

      • Archive3.r02

      • Archive3.r04

      • Archive3.r05

      • zzz.txt

      我不得不开始与下面的链接脚本要做到这一点,但脚本不能做我想做的,于是我又开始了新的问题。

      I had start to do this with the script in the link below, but that script can't do what I want, so I have started a new question.

      <一个href=\"http://stackoverflow.com/questions/31419391/how-to-unpack-all-rar-archives-in-all-subfolders-of-a-folder-and-then-delete-the\">How解开所有的RAR压缩文件夹中的所有子文件夹,然后删除档案?

      在以上unrars在所有子文件夹中的所有文件,然后该链接的脚本文件夹,其文件移动到一个新的位置。我想脚本unrars和源文件夹移到子文件夹的子文件夹。

      The script in the link above unrars all files in all subfolders and then moves the folder with its files to a new location. I want that the script unrars and moves subfolder for subfolder in the source folder.

      Edit.1

      如果WinRAR是准备好第一个子文件夹中的源文件夹结构应该是这样的:

      If winrar is ready with the first subfolder the structure in the source folder should look like this:


      • 源文件夹

        • subfolder2

          • Archive2.r00

          • Archive2.r01

          • yyy.txt


          • Archive3.r00

          • Archive3.r01

          • Archive3.r02

          • Archive3.r04

          • Archive3.r05

          • zzz.txt

          在文件和文件夹 C:\\用户\\新位置应该是这样的:

          The files and folders in C:\Users\new-location should look like this:


          • 源文件夹

            • subfolder1

              • xxx.mp4

              • xxx.txt


              • yyy.mp4

              • yyy.txt


              • zzz.mp4

              • zzz.txt

              推荐答案

              一个可能的一批code这个任务是:

              A possible batch code for this task is:

              @echo off
              setlocal EnableDelayedExpansion
              set "BaseSourceFolder=C:\Users\Unpack"
              set "BaseTargetFolder=C:\Users\New-Location"
              for /D %%D in ("%BaseSourceFolder%\*") do (
                  set "TargetFolder=%BaseTargetFolder%\%%~nxD"
                  if not exist "!TargetFolder!" md "!TargetFolder!"
                  "%ProgramFiles%\WinRAR\Rar.exe" x -cfg- -idq -y "%%~fD\*.r??" "!TargetFolder!"
                  if not errorlevel 1 (
                      del /F /Q "%%~fD\*.r??"
                      move /Y "%%~fD\*" "!TargetFolder!">nul 2>nul
                      rd "%%~fD" 2>nul
                  )
              )
              rem rd "%BaseSourceFolder%" 2>nul
              endlocal
              

              为/?在命令提示符窗口中显示帮助的命令执行对带参数 / D ,这意味着在基源文件夹中 * 。

              for /? executed in a command prompt window displays help for command for with parameter /D which means for each directory matched by * in base source folder.

              在循环第一目标文件夹名称是基于子处理的名称来定义。 %%〜fD的 %%〜NXD 也由的解释/?其中文件夹通常不具备的延伸,因而 %%〜ND 往往也够了。

              In the loop first the target folder name is defined based on name of the subfolder to process. %%~fD and %%~nxD are also explained by for /? whereby folders usually do not have an extension and therefore %%~nD is often also enough.

              接下来该目标文件夹中创建如果不是已经存在的。

              Next this target folder is created if not already existing.

              然后 RAR.EXE 执行到当前子文件夹中多卷档案中抽取直接定义的目标文件夹。

              Then Rar.exe is executed to extract the multi-volume archive in the current subfolder directly to the defined target folder.

              * R'是用来做与旧的命名方案多卷文件这个批处理文件的工作 ArchiveName.r00 ArchiveName.r01 ,......以及更好的命名方案 ArchiveName.part01.rar ArchiveName.part02.rar ,...这是默认使用通过的 WinRAR的的版本5.21。的 RAR 的自动跳过从列表中匹配 * R'多卷档案的提取过程中已处理的存档文件。

              *.r?? is used to make this batch file work for multi-volume archives with old naming scheme ArchiveName.r00, ArchiveName.r01, ... as well as better naming scheme ArchiveName.part01.rar, ArchiveName.part02.rar, ... which is used by default by WinRAR version 5.21. RAR automatically skips the archive files processed already during extraction of a multi-volume archive from the list matching *.r??.

              退出code 进行评估,以确定是否发生了任何错误。如果退出code指定为错误级别低于1,没有错误和如果分会3命令执行导致先删除所有的RAR压缩文件

              Exit code of Rar.exe is evaluated to determine if any error occurred. If exit code assigned to errorlevel is lower than 1, there was no error and the 3 commands of the if branch are executed resulting in deleting first all RAR archive files.

              在当前的子文件夹中剩下的文件也移到这是当前的目标文件夹中的 *。txt的文件夹结构的例子。

              The remaining files in current subfolder are also moved to the current target folder which is the *.txt file in the folder structure example.

              由于目前的子文件夹现在应该是空的,命令的 RD 应能删除该目录。在一个错误,因为子文件夹仍然不是空的情况下,子文件夹仍然是基源文件夹中。

              As the current subfolder should be empty now, the command rd should be able to remove the directory. In case of an error because subfolder is still not empty, the subfolder remains in base source folder.

              基源文件夹为空,如果一切工作没有错误。后的注释行循环可以用来删除空基源文件夹为好,但保留文件夹如果有什么失败。

              The base source folder is empty if everything worked without an error. The commented line after for loop could be used to remove the empty base source folder as well, but keep the folder if anything failed.

              这篇关于如何从一个文件夹的子文件夹中提取所有多卷RAR压缩文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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