Winrar命令行不会删除递归

Winrar命令行不会删除递归

本文介绍了不使用通配符时,Winrar命令行不会删除递归的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用命令行删除WinRar存档中的某些文件.

I'm trying to delete some files in a WinRar Archive using the Command Line.

Rar文件:

/testing.rar
/testing.rar/some-data.txt
/testing.rar/testing/some-data.txt

这是我的代码:

cd "C:\Program Files\WinRAR\" && rar d -cl -r "c:\full\path\testing.rar" some-data.txt

它仅删除根目录中的some-data.txt文件,而不删除/testing/

It only deletes the some-data.txt file in the root, not inside /testing/

使用

cd "C:\Program Files\WinRAR\" && rar d -cl -r "c:\full\path\testing.rar" some-data.*

(将扩展名更改为.*),它确实删除了两个文件.

(changed the extension to .*) it does delete both files.

我做错什么了吗?

谢谢,安德烈.

推荐答案

虽然d命令无法处理它,但是简单的管道可以处理它

While the d command can not handle it, a simple pipe can deal with it

@echo off
    setlocal enableextensions disabledelayedexpansion

    set "rar=C:\Program Files\WinRar\rar.exe"
    set "archive=c:\full\path\testing.rar"

    (
        %= List archive contents =%
        "%rar%" lb -ed "%archive%"
    )|(
        %= filter the list for the file in any subfolder =%
        findstr /i /e /l /c:"\somedata.txt"

        %= and include the root file =%
        echo somedata.txt
    )|(
        %= Delete from archive the list of files read from stdin =%
        "%rar%" d -cl -n@ "%archive%"
    )

第二步(过滤归档文件列表)在findstrecho中分开,只是为了防止输出中不存在要删除的文件的情况.没有文件列表,-n@修饰符(读取要从stdin中删除的文件)将不会读取任何内容,并且所有存档内容都将被删除.

The second step (filter the list of files in archive) is splited in the findstr and the echo just to prevent the case when the file to be deleted is not present in the output. Without a list of files the -n@ modifier (read files to delete from stdin) will not read anything and all the archive contents will be removed.

这篇关于不使用通配符时,Winrar命令行不会删除递归的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-02 00:03