extract .zip files from multilple locations with Batch or Script file

Tellu Wsup 21 Reputation points
2021-09-02T16:46:54.3+00:00

I have a bunch of folders that contain .zip files. is it possible to run a batch that will search for zip files in multiple folders and automatically unzip them in the parent folder?

Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,456 questions
{count} votes

Accepted answer
  1. Andreas Baumgarten 103.8K Reputation points MVP
    2021-09-02T18:14:14.74+00:00

    Hi @Tellu Wsup ,

    maybe this helps: https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.archive/expand-archive?view=powershell-7.1

    Very simple approach:

    Get-ChildItem *.zip | Expand-Archive  
    

    If you already have a script it would be helpful to post it here. It's easier to help that way.

    ----------

    (If the reply was helpful please don't forget to upvote and/or accept as answer, thank you)

    Regards
    Andreas Baumgarten


1 additional answer

Sort by: Most helpful
  1. Limitless Technology 39,501 Reputation points
    2021-09-03T11:41:28.897+00:00

    Hello,

    First you will need to have 7zip installed on the machine, then create a BAT file in the parent folder with content:

    FOR /D /r %%F in ("") DO (
    pushd %CD%
    cd %%F
    FOR %%X in (
    .rar *.zip) DO (
    "<7zipfolderandfilepath>" x "%%X"
    )
    popd
    )

    *replace <7zipfolderandfilepath> for the folder where 7zip is installed (for example: C:\Program Files\7-zip\7z.exe)

    Hope it helps!

    Best regards,

    0 comments No comments