I wrote a PowerShell command to zip a folder and its subdirectories while excluding files from the main directory.
When I execute the command it does create the zip file with all subdirectories within, but it doesn't seem to understand that subdirectories are in the same pipeline as the main files.
├── _subfolder
| └── file.json
├── file.js
└── file.html
So, when I try to open the zip in Firefox's Debugger, I get the following error:
Loading locale file _subfolder/file.json: Error: Error while loading 'jar:file:///C:/Users/xxx/Desktop/folder/archive.zip!/_subfolder/file.json' (NS_ERROR_FILE_NOT_FOUND)
Here's my current code:
# Target Path
$path = "c:\users\xxx\desktop\folder-to-zip\"
# Archive Path
$destination = "C:\users\xxx\desktop\folder\archive.zip"
# Exclude some files in the main folder
$exclude = "file.js"
# Choose files to zip
$files = Get-ChildItem $path -Exclude $exclude
#Compressing archive
Compress-Archive -Update -Path $files -DestinationPath $destination -CompressionLevel Fastest
How can I make sure the zip includes some information about the hierarchy of the files? When I zip manually with WinRAR, I get no error.