2015-08-14 43 views
0

例如,如果在我的当前目录中,我有:如何将包含多个文件的包解压缩到单独的目录中?

AAA.zip 
BBB.zip 
CCC.zip 

的每一个* .zip文件有

123.csv 
456.csv 
789.csv 

我怎么能解压缩所有包到各自的目录,所以我有:

-AAA 
+--- 123.csv 
+--- 456.csv 
+--- 789.csv 
-BBB 
+--- 123.csv 
+--- 456.csv 
+--- 789.csv 
-CCC 
+--- 123.csv 
+--- 456.csv 
+--- 789.csv 

预先感谢您的宝贵时间

回答

0

您可以编写一个脚本DOS或等值的bash

For each file in the directory 

    if file has .zip extension 

     get the name of that file 

     make directory with the name 

     copy zip file to the directory 

     unzip the zip file in that directory 
+0

我的歉意,应该很久以前发布我的答案。我遵循你的建议,而且效果很好。非常感谢你。 – user3638172

0

我想张贴我作为由@Abhi给出的答案评论回应,但我失败了。仍然学习关于stackoverflow和关于使用bash!我使用的脚本是:

dir=/directory/with/zip/files 

for i in $(ls $dir | grep zip); do 

zip_folder=$(echo $i | rev | cut -c 5- | rev) 

mkdir $dir/$zip_folder 

mv $dir/$i $dir/$zip_folder 

cd $dir/$zip_folder 

unzip $i 

cd $OLDPWD 

done 
+0

但问题是关于zip文件。你想发布你的解决方案真好,但寻找'tar'文件解决方案的人可能在这里找不到它。建议删除,因为你的答案没有增加价值(w.r.t.发布的问题)。 –

+0

你说得对。将改变这个并发布一个解决方案的实际问题。 (zip文件) – user3638172

相关问题