Created
July 16, 2020 06:25
-
-
Save rytsikau/62df29583710cf3aaf6e1be8b005a571 to your computer and use it in GitHub Desktop.
Listing files contained inside zip archives of a specified folder
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#------------------------------------------------------------------------------ | |
# Listing files contained inside zip archives of a specified folder | |
#------------------------------------------------------------------------------ | |
#<#---------------------------------------------------------------------------- | |
function ListFilesInZips ([string]$inputFolder) | |
{ | |
add-type -assembly System.IO.Compression.FileSystem | |
foreach ($zipFile in (get-childitem $inputFolder -filter '*.zip')) | |
{ | |
$zipContent = [IO.Compression.ZipFile]::OpenRead($zipFile.FullName) | |
$list += $zipContent.Entries.FullName | ?{ $_ -notmatch '\/$' } ` | |
| %{ "$zipFile`:$_" } | |
$zipContent.Dispose() | |
} | |
return $list | |
} | |
#----------------------------------------------------------------------------#> | |
ListFilesInZips "c:\folderWithZips" | out-file "list.txt" | |
#------------------------------------------------------------------------------ | |
# If zip archive(s) contain file names with non-latin characters, | |
# use function "ConvertTo-Encoding", which can be found here: | |
# https://xaegr.wordpress.com/2007/01/24/decoder | |
# For example: | |
# ListFilesInZips "c:\folderWithZips" | ConvertTo-Encoding cp866 windows-1251 ` | |
# | out-file "list.txt" | |
#------------------------------------------------------------------------------ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment