自动解压文件

发布于 2024-09-25 16:32:43 字数 135 浏览 9 评论 0原文

我有一个充满压缩文件的文件夹(大约 200 个)。我想将其转换为仅包含解压缩文件的文件夹。做到这一点最简单、最快的方法是什么?

请注意,我想在解压缩后从文件夹中删除压缩文件。

另外,我用的是 Mac。

谢谢!

I have a folder full of zipped files (about 200). I would like to transform this into a folder consisting only of unzipped files. What would be the easiest and quickest way to do this?

Please note that I would like to remove the zipped file from the folder once it us unzipped.

Also, I'm on a Mac.

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

暖阳 2024-10-02 16:32:43

您可以执行以下操作:

for file in `ls *.zip`; do unzip -f $file; rm $file; done

我们循环遍历目录中的所有 zip 文件,将其解压缩,然后将其删除。

请注意,zip-f 选项将覆盖任何文件,而不会提示是否发现重复文件。

您需要从包含所有 zip 文件的目录在命令行上运行上述一行命令。这一行相当于:

for file in `ls *.zip` # ls *.zip gets the list of all zip file..iterate through that list one by one.
do             # for each file in the list do the following:
unzip -f $file # unzip the file.
rm $file       # delete it.
done

You can do something like:

for file in `ls *.zip`; do unzip -f $file; rm $file; done

We are looping through all the zip files in the directory, unzipping it and then deleting it.

Note that the -f option of zip will overwrite any file without prompting if it finds a duplicate.

You need to run the above one-line command on the command line from the directory that has the all the zip files. That one line is equivalent to:

for file in `ls *.zip` # ls *.zip gets the list of all zip file..iterate through that list one by one.
do             # for each file in the list do the following:
unzip -f $file # unzip the file.
rm $file       # delete it.
done
只想待在家 2024-10-02 16:32:43

我发现这个答案这是一个简单的答案liner 用于gunzip 文件夹内的所有.gz 压缩文件。

基本上你 cd 到该文件夹​​然后运行

gunzip *.gz

​​如果你只想解压具有特定前缀的文件,你可以将其放在 *

gunzip example*.gz

Easy as cake!之前!

I found this answer which is a simple one liner to gunzip all .gz compressed files within a folder.

Basically you cd to the folder and then run

gunzip *.gz

If you want to only unzip files with a certain prefix you put that before the *

gunzip example*.gz

Easy as cake!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文