简体   繁体   English

get-childitem 在不同的 zip 文件中查找特定文件

[英]get-childitem to find specific files within different zip files

I'm trying to some files with the same keyword in the title, across different zip files, within the same folder on a fileserver.我正在尝试在文件服务器上的同一文件夹中跨不同的 zip 文件处理一些标题中具有相同关键字的文件。

I've got the following script to show all zip files, but how do I find the specific file with the same keyword in the titel, across all zip files.我有以下脚本来显示所有 zip 个文件,但是如何在所有 zip 个文件中找到标题中具有相同关键字的特定文件。

$searchinfolder = '\\fileserver\path\path2\path3\path4(here are all the sub folders where the zip files are located within)\'
Get-ChildItem -Path $searchinfolder -Recurse 

Now I want to know how I can find the specific file across all zip files现在我想知道如何在所有 zip 个文件中找到特定文件

Found this article: https://devblogs.microsoft.com/scripting/powertip-use-powershell-to-read-the-content-of-a-zip-file/找到这篇文章: https://devblogs.microsoft.com/scripting/powertip-use-powershell-to-read-the-content-of-a-zip-file/

To make it easier I just added a filepath variable you can put the path of the zip file there.为了方便起见,我刚刚添加了一个文件路径变量,您可以将 zip 文件的路径放在那里。

$filepath = "C:\temp\zippy.zip" #declare filepath

Add-Type -assembly "system.io.compression.filesystem" #loads assembly to be able to run additional commands

[io.compression.zipfile]::OpenRead($filepath).Entries.Name #command to get filenames inside zip files

Hope that helps!希望有帮助!

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

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