简体   繁体   English

如何在linux中分别压缩多个文件夹

[英]How to zip multiple folders separately in linux

Below mentioned folders contain some data.下面提到的文件夹包含一些数据。 I need to zip all the folders separately.我需要分别压缩所有文件夹。

ItembankUpdate-20210602-NGSS-1       
ItembankUpdate-20210602-NGSS-4  
ItembankUpdate-20210602-NGSS-7
ItembankUpdate-20210602-NGSS-3      
ItembankUpdate-20210602-NGSS-5  
ItembankUpdate-20210602-NGSS-8
ItembankUpdate-20210602-NGSS-2      
ItembankUpdate-20210602-NGSS-6

With this Command, I can zip only one folder使用此命令,我只能压缩一个文件夹

zip -r ItembankUpdate-20210602-NGSS-3.zip ItembankUpdate-20210602-NGSS-3

How can I zip all the folders separately at once?如何一次单独压缩所有文件夹?

First, make sure that you are in the directory where the above mentioned folders are.首先,确保您位于上述文件夹所在的目录中。 Then run:然后运行:

find . -type d -maxdepth 1 -execdir zip '{}.zip' '{}' \\;

This will find all the directories and zip them with the names:这将找到所有目录并使用名称压缩它们:

ItembankUpdate-20210602-NGSS-1.zip
ItembankUpdate-20210602-NGSS-4.zip
ItembankUpdate-20210602-NGSS-7.zip
ItembankUpdate-20210602-NGSS-3.zip
ItembankUpdate-20210602-NGSS-5.zip
ItembankUpdate-20210602-NGSS-8.zip
ItembankUpdate-20210602-NGSS-2.zip
ItembankUpdate-20210602-NGSS-6.zip

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM