Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filter on directory names and recursion #22

Open
slestak opened this issue Aug 8, 2016 · 5 comments
Open

Filter on directory names and recursion #22

slestak opened this issue Aug 8, 2016 · 5 comments

Comments

@slestak
Copy link

slestak commented Aug 8, 2016

Trying to recursively pack a selection of files and directories. The resulting zip file is does not have the contents I would expect.

2016-08-08 08_32_54-windows powershell

The item on the left was created in windows explorer using the 7zip gui.

Note that the item on the right has all of the folders in the source path. This can be seen by 2 points, the folder count is 835, and the "Testing" string lists folder 1305584 which should not be present.

I am assuming that recursion did not occur because even though there were more input objects to the item on the right, the archive size is smaller.

2016-08-08 08_33_19-windows powershell

I might be able to look at this later, but wanted to get you the example in case I am misunderstanding something or it is a trivial fix.

@thoemmi
Copy link
Owner

thoemmi commented Sep 12, 2016

Can you provide me with a simple example, which can help me to reproduce the issue?

@slestak
Copy link
Author

slestak commented Oct 4, 2016

Getting this together for you today

@slestak
Copy link
Author

slestak commented Oct 4, 2016

Here is a script to simulate the directory structure I was dealing with that day. I have simplified a bit, but the basic gist is, I would expect the matching folders and their contents to be archived.
Issue22_Example.txt

@thoemmi
Copy link
Owner

thoemmi commented Oct 7, 2016

Hi @slestak thanks for the repro.

The reason for the empty ZIP file is that -Filter only refers to file names. 7Zip4PowerShell uses SevenZipSharp, and you can see the file filtering in SevenZipCompressor.AddFilesFromDirectory. So filtering directories and compressing their contents doesn't work this way.

Here's the command which I think will get the result you're expecting:

gci -Path .\1305\13050* -Recurse -Include *.csv | Compress-7Zip -Format Zip -ArchiveFileName .\13050_001_099.zip

This command first gets all CSV files in directories matching .\1305\13050* using Get-ChildItem, and passes this list to Compress-7Zip.

I'm afraid that the -Filter parameter is misleading. Maybe I'll make it obsolete in a future version.

@pveloso
Copy link

pveloso commented Feb 28, 2017

I too am looking for a way to preserve the directory structure and every permutation of parameters (including using gci as shown above) doesn't preserve the structure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants