I would like to use tar
(on Windows) in a command line to extract files from an archive, that has a variable name, like *-archive.zip
, that I don't know beforehand. I haven't found a way to use a wildcard for the targeted archive name, is there an option to do that ?
I have tried things like tar -xf "*-archive.zip"
, but it searches for a file with the same exact name, not the pattern.
Thanks.
The proper solution is (as Mofi suggested) :
for %I in (*-archive.zip) do tar.exe -xf "%I"
But what I ended up doing is switching to PowerShell, and ditching tar
that cannot handle PowerShell pipes. The final command is :
Get-ChildItem -Name -Filter *-archive.zip | Expand-Archive
It works provided there is only one file matching the pattern in the current working folder.