Home > database >  Extract File with no extension via 7-zip through Powershell
Extract File with no extension via 7-zip through Powershell

Time:04-06

I have the below files (Datamashup files of PowerBI) which do not have any extensions. enter image description here

We manually extract the file via 7-zip tool as below:

enter image description here

How can one extract it via powershell ?

Note: I tried leveraging Expand-7Zip module but it is not working as the file extension is unknown.

CodePudding user response:

@zett42 fyi 7zip removed 7za, just 7z is the cmdline tool now.

@Nandan, just replace the folder path below with your folder path

get-childitem c:\temp\ -File -Filter *. | %{& 7z e $_.FullName}

Or if you place the script in the same folder:

get-childitem $PSScriptRoot -File -Filter *. | %{& 7z e $_.FullName}

Note: You'll need to add 7zip to your Path variable as well, alternatively just reference the full path to the 7z exe e.g. "C:\Program Files\7-Zip\7z.exe"

edit2: If you want to stick with windows only do the below.

get-childitem $PSScriptRoot -File -Filter *. | %{Expand-Archive $_.FullName}
  • Related