首页 > 解决方案 > 从 Windows 目录中的所有 zip 中删除 __MACOSX 文件夹和 .DS_Store 文件

问题描述

我在某个目录上有一个相当大的 zip 文件列表,每个目录都包含一个 __MACOSX 文件夹和 .DS_Store 文件。有什么办法可以运行一些批处理来从每个 zip 中删除文件夹和文件,而不必先解压缩它们?我不太喜欢 shell 脚本,我尝试了一些命令无济于事。

标签: windowsmacosbatch-filedirectoryzip

解决方案


这个答案假设您有办法在 Windows 上运行 zip 程序和 bash。

IE。使用适用于 Windows 10 的 Ubuntu shell https://tutorials.ubuntu.com/tutorial/tutorial-ubuntu-on-windows

  1. 为 Windows 启用 Ubuntu
  2. sudo apt-get update; sudo apt-get install -y zip

一旦你有一个兼容的环境

  1. 首先备份您的 zip 文件目录,以防此命令在您的系统上无法正常工作。

  2. 其次,如果您使用 bash 并安装了 zip 程序,请运行以下命令。

cd $directory_with_zips

for file in `ls`; do echo $archive; zip -d $archive __MACOSX; done

https://superuser.com/questions/600385/remove-single-file-from-zip-archive-on-linux


推荐阅读