重命名根据批量压缩文件解压缩文件 [英] Rename extracted file based on zip file in Batch

查看:223
本文介绍了重命名根据批量压缩文件解压缩文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有名字,如001.zip,002.zip,003.zip多个zip文件,必须去到999.zip的潜力。每一个zip文件都有一个确切的文本文件。我想用批量提取每个zip文件,然后将其重命名提取到压缩文件名的文本文件。

例如,如果我提取001.zip,我想要那个被提取(提取得到的所有文本文件有不同的名字)是名001.txt文本文件。

我至少我现在提取所有文件,但我与批太陌生了,我不知道如果有一个简单的方法来做到这一点?

  CD测试
回声DECOM pressing zip4数据。
7Z E * .zip文件


解决方案

试试这个

  MD TEXTFILES
在%% F(* .7z压缩)做(
7Z E%% F
移动* .TXT TEXTFILES \\ %%〜nf.txt

XCOPY TEXTFILES \\ *。txt的originalfolder
RD TEXTFILES / S / Q

只要确保有此文件夹中任何现有的文本文件,这应该工作。它只是创建一个临时文件夹,然后将所有文本文件有(仅提取一会的时候present但这个工程作为文件名不知道),并将其重命名为zip文件名。

在所有的提取和重命名完成它只是移动所有TEXTFILES回原来的文件夹,删除临时之一。

希望这有助于。

I have multiple zip files with names such as 001.zip, 002.zip, 003.zip and have the potential to go up to 999.zip. Each zip file has exactly one text file. I would like to extract each zip file using Batch, and then rename the text file it extracted to the file name of the zip.

For example, if I extract 001.zip, I want the text file that gets extracted (all the text files that get extracted have different names) to be name 001.txt.

I at least am extracting all the files right now, but I am too unfamiliar with Batch, and am not sure if there is a simple way to do this?

cd test
echo     Decompressing zip4 data.
7z e *.zip

解决方案

Try this

md textfiles
for %%f in (*.7z) do (
7z e "%%f"
move *.txt textfiles\%%~nf.txt
)
xcopy textfiles\*.txt originalfolder
rd textfiles /s /q

Just make sure there are no existing text files in this folder and this should work. It just creates a temporary folder and moves all text files there (only the extracted one will be present at the time but this works as the filename is not known) and renames it to the zip file name.

After all the extractions and renames are done it just moves all the textfiles back to the original folder and deletes the temporary one.

Hope this helps.

这篇关于重命名根据批量压缩文件解压缩文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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