Unzip multiple bzip files thru powershell

Hello there-
I have 50 directories. Each directory has 10 sub directories in which there are 300 bz2 files. I would like to unzip them thru bzip program. Is it possible to do so with powershell/batch/cmd line script?
Dir1>Subdir1>*.bz2
      >Subdir2>*.bz2
      >Subdir10>*.bz2
Dir2>Subdir1>*.bz2
      >Subdir2>*.bz2
      >Subdir10>*.bz2
Thanks,
Ben

Hi,
To unzip files, I would like suggest you refer below code, those code is to find all current location zip files and unzip them to the current location:
$shell=new-object -com shell.application
$CurrentLocation=get-location
$CurrentPath=$CurrentLocation.path
$Location=$shell.namespace($CurrentPath)
$ZipFiles = get-childitem *.zip
$ZipFiles.count | out-default
foreach ($ZipFile in $ZipFiles)
$ZipFile.fullname | out-default
$ZipFolder =
$shell.namespace($ZipFile.fullname)
$Location.Copyhere($ZipFolder.items())
If you want to unzip many location files, we could use get-childitem to get all of them and saved in a variable.
For more details, please refer to the below link:
PowerShell script to unzip many files
http://www.techiebirdsnest.com/2009/01/powershell-script-to-unzip-many-files.html
Hope this helps.
Regards,
Yan Li
Yan Li
TechNet Community Support

Similar Messages

  • Split large .pptx file to multiple files using PowerShell

    Hi.
    I'm not a programmer and I have the task to split big .pptx file(>100 slides) to multiple .pptx files with 4 slides in each one and save them into SP library. It should be done on PowerShell.
    Thanks for any help!

    Hi,
    For splitting PowerPoint files into multiple parts, I would suggest you post this question to Office forum, you will get more help and confirmed answers there:
    http://social.technet.microsoft.com/Forums/office/en-US/home
    For uploading files to SharePoint Library using PowerShell, here are some links with script demos provided for your reference:
    http://social.technet.microsoft.com/wiki/contents/articles/19529.sharepoint-2010-upload-file-in-document-library-using-powershell.aspx
    http://spfileupload.codeplex.com/
    Best regards
    Patrick Liang
    TechNet Community Support

  • Unzipping nested files in powershell

    # Initially clear screen
    clear-host
    # Set up initial Paths
    $destination = “C:\Users\paul__000\Documents\Test\unzipped"
    $b = 'C:\Users\paul__000\Documents\Test\Reports\Archive\Adjusted_prices_Reports'
    # Set up working files - for establishing initial directories and files
    $bb = 'C:\Users\paul__000\Documents\Test\Test00.txt'
    $bc = 'C:\Users\paul__000\Documents\Test\Test01.txt'
    # Setup path - keep track of initial directory - and establish path to allow relative addressing
    $a = Get-Location
    Set-Location $b
    # Establish files for both folders and zip files
    get-childitem | format-table name | out-file $bb
    $c =get-content $bb
    $d = $c.count
    # Disgard surplus info & only keep directory and file name information (Not sure why count initially was 31 !!! : hence the need for -3 in next statement)
    $c = $c[3..($d-3)] | out-file $bb
    $c = Get-Content $bb | out-file $bc
    $c = Get-content $bc
    $d = $c.count
    $c = $c[0..($d-1)] | out-file $bc
    $c = get-content $bc
    $d = $c.count
    # establish folder names - by replacing .zip or .ZIP with \
    $d
    $count = 0
    do {
    $c[$count] = $c[$count].replace(".ZIP","\")
    $c[$count] = $c[$count].replace(".zip","\")
    $count=$count + 1
    until ( $count -gt ($d-1) )
    $c | out-file $bc
    $c = get-content $bc
    # Setup path - keep track of initial directory - and establish path to allow relative addressing
    $xxx = Get-Location
    Set-Location ($destination + "\")
    # set up folders
    $d
    $count = 0
    do {
    $k = $c[$count]
    New-Item -itemtype directory -path $k
    $count =$count +1
    until ( $count -gt ($d-1) )
    Set-Location $xxx
    # Establish a Expand-ZipFile function
    function Expand-ZIPFile($file, $destination)
    $file, $destination
    $file = "$file"
    $destination = "$destination"
    # help help help - it looks like i have send the correct parameters but i get the error:
    # You cannot call a method on a null-valued expression.
    # At C:\Users\paul__000\Documents\Powershell rj\Untitled26.ps1:70 char:19
    $shell = new-object -com shell.application
    $zip = $shell.NameSpace($file)
    foreach($item in $zip.items())
    $shell.Namespace($destination).copyhere($item)
    # Establish both - files to unzip and folders to store them in - parameters are passed to 'function Expand-ZIPFile'
    # This is where error occurs
    $c = get-content $bc
    $e = get-content $bb
    $f = $e.count
    $c , $e , $f
    $count=0
    do {
    $e[$count] = $b + '\' + $e[$count]
    $c[$count] = $destination + '\' + $c[$count]
    Expand-ZIPFile –File $e[$count] –Destination $c[$count]
    $count = $count + 1}
    until ($count -gt ($f-1))
    # end of main code
    ## This is standalone code which works successfully
    function Expand-ZIPFile($file, $destination)
    $shell = new-object -com shell.application
    $zip = $shell.NameSpace($file)
    foreach($item in $zip.items())
    $shell.Namespace($destination).copyhere($item)
    $mmm =“C:\Users\paul__000\Documents\Test\Reports\Archive\Adjusted_prices_Reports\PUBLIC_PRICE_REVISION_DISPATCH_20110101.ZIP ”
    $nnn =“C:\Users\paul__000\Documents\Test\unzipped\PUBLIC_PRICE_REVISION_DISPATCH_20110101\"
    Expand-ZIPFile –File $mmm –Destination $nnn
    The main concern is the use of a function called Expand-ZIPFILE which is used for unzipping nested zip files. 2 parameters are supplied, the file to be unzipped and the folder for showing the unzipped files. As it is a nested zip files these are zip files which also need to be unzipped. The code has not been written for this yet. I have placed a stand alone function at the bottom of my code which works perfectly. However when I try and run in the main body of code and pass parameters to the function it fails at line 70. Error message : You can not call a method on a null valued expression. I hope you can assist on this matter.Looking forward to your expert assistance.Roger
    

    Thanks for the code.
    I used it but changed the file and folder locations.
    It appeared to work, however in the 2 successive runs of the code, 2 different errors were announced at the PS Console. The errors are shown as follows:
    Second Run Error Message followed by First Run Error Message
    clear-host
    #File used 'C:\Users\paul__000\Documents\Test\Reports\Archive\Adjusted_prices_Reports\PUBLIC_PRICE_REVISION_DISPATCH_20110101.ZIP' instead of 'c:\scripts\scripts.zip'
    #Directory used 'C:\Users\paul__000\Documents\Test\unzipped\PUBLIC_PRICE_REVISION_DISPATCH_20110101\' instead of 'c:\temp\'
    # load support classes\
    $zipfile='C:\Users\paul__000\Documents\Test\Reports\Archive\Adjusted_prices_Reports\PUBLIC_PRICE_REVISION_DISPATCH_20110101.ZIP'
    [System.Reflection.Assembly]::LoadWithPartialName("System.IO.Compression")
    #openand archive
    $archive = New-Object System.IO.Compression.ZipArchive(New-Object System.IO.FileStream($zipfile,'Open'))
    # list contents
    # $archive
    $archive.Entries|select name,length,fullname
    # extract a file
    $entry=$archive.GetEntry('scripts/config.ini')
    # $entry
    $target='C:\Users\paul__000\Documents\Test\unzipped\PUBLIC_PRICE_REVISION_DISPATCH_20110101\'
    # $target
    [System.IO.Compression.ZipFileExtensions]::ExtractToFile($entry, $target+$entry.Name, $true)
    $archive.Dispose();
    # Extract a zipfile
    [System.Reflection.Assembly]::LoadWithPartialName("System.IO.Compression.FileSystem")
    [System.IO.Compression.ZipFile]::ExtractToDirectory('C:\Users\paul__000\Documents\Test\Reports\Archive\Adjusted_prices_Reports\PUBLIC_PRICE_REVISION_DISPATCH_20110101.ZIP','C:\Users\paul__000\Documents\Test\unzipped\PUBLIC_PRICE_REVISION_DISPATCH_20110101\')
    write-host "Results"
    get-childitem 'C:\Users\paul__000\Documents\Test\unzipped\PUBLIC_PRICE_REVISION_DISPATCH_20110101\'
    # create a zip archive
    #[System.IO.Compression.ZipFile]::CreateFromDirectory('c:\scripts','c:\temp\scripts.zip')

  • How to Read the "text file and csv file" through powershell Scripts

    Hi All
    i need to add a multiple users in a particular Group through powershell Script how to read the text and CSV files in powershell
    am completly new to Powershell scripts any one pls respond ASAP.with step by step process pls
    Regards:
    Rajeshreddy.k

    Hi Rajeshreddy.k,
    To add multiple users to one group, I wouldn't use a .csv file since the only value you need from a list is the users to be added.
    To start create a list of users that should be added to the group, import this list in a variable called $users, the group distinguishedName in a variable called $Group and simply call the ActiveDirectory cmdlet Add-GroupMember.
    $Users = Get-Content -Path 'C:\ListOfUsernames.txt'
    $Group = 'CN=MyGroup,OU=MyOrg,DC=domain,DC=lcl'
    Add-ADGroupMember -Identity $Group -Members $Users

  • How to get the content of a website to a txt file via powershell

    Hello,
    I have a reporting server that creates a report to a URL, by running multiple .xsl files. I want to be able to gather the data in the URL and convert it to csv or txt file via powrshell.
    Again I want the data inside the URL, I've been playing around Net.Webclient but I'm not getting what I need.

    If you're using PowerShell 3.0 or later you can try using Invoke-WebRequest.
    This previous thread shows how you can download the content from the page.
    Without knowing what type of content (i.e. text vs images vs other objects) is on the page it's hard to say if this will work for you.
    Jason Warren
    @jaspnwarren
    jasonwarren.ca
    habaneroconsulting.com/Insights

  • How to rearrange the contents of multiple PST files

    Hi,
    I have been trying to find a way of moving items within multiple PST files based specific criteria, but as of yet I haven't and was hoping that someone might be able to suggest whether or not it was possible using Powershell, or a third party tool.
    The scenario I have is that I've exported numerous user archives to PST file based purely on items that have attachments, unfortunately there are a large number of items that consider the email signatures to be attachments and I need to find a way of moving
    these items into a new folder within the PSTs.
    I know it's possible to do it individually via Outlook but that isn't practical in this situation. Please can anyone point me in the right direction?
    Thanks

    In order to read the content of the Redo Log files, you should use Logminer Utility
    Please refer to the documentation for more information:
    [Using LogMiner to Analyze Redo Log Files|http://download.oracle.com/docs/cd/B19306_01/server.102/b14215/logminer.htm#SUTIL019]
    Kamran Agayev A. (10g OCP)
    http://kamranagayev.wordpress.com
    [Step by Step install Oracle on Linux and Automate the installation using Shell Script |http://kamranagayev.wordpress.com/2009/05/01/step-by-step-installing-oracle-database-10g-release-2-on-linux-centos-and-automate-the-installation-using-linux-shell-script/]

  • Append a top line to multiple txt files

    Hi there,
    I have to manipulate txt files in powershell and I may not be very good at it... so any help is welcome ^^
    I've got multiple files in a single folder. They are exports from a DB and are formatted like that :
    "name1"
    "name2"
    "name3"
    I need them to be :
    =1
    name1
    name2
    name3
    In short I have to remove all the quotes and add "=1" on the first line of each file.
    Here's what I've got so far :
    $fileEntries = [IO.Directory]::GetFiles("C:\temp");
    foreach($fileName in $fileEntries)
    (Get-Content $fileName) |
    Foreach-Object {$_ -replace '"', "" } |
    Set-Content $fileName
    foreach($fileName in $fileEntries)
    Write-Output "=1`n" | Out-File $fileName -Append
    It appends at the last line, I just can't get the "=1" at the top... any help would be much appreciated !
    Thanks !

    Hi,
    This will do what you're after:
    Get-ChildItem C:\Temp -File | ForEach {
    $stripped = (Get-Content $_.FullName).Replace('"','')
    Write-Output '=1' | Out-File $_.FullName
    $stripped | Out-File $_.FullName -Append
    Don't retire TechNet! -
    (Don't give up yet - 12,830+ strong and growing)

  • Unzip (a zip file that has pdf files and a csv)

    Here is my requirement:
    Receive a zip file (that contains PDF files and a CSV file) in BizTalk
    Each record in CSV has a field which identifies the PDF files (by pdf file name) associated with it
        For Example - record id on each row in CSV file identifies the pdf files associated with it,
                             pdf files have names starting with recordid_sequence number.pdf i.e. 11111_1.pdf, 11111_2.pdf, 
                             11111_3.pdf...
    Create two new zip files based on record id on the record in CSV file
        For example - one zip file with a new CSV and related pdf files for record id range 1 to 5000
                             another zip file with a new CSV and related pdf filesfor all other record ids
    using BTS2010!!
    "custom flat file disassembler component" or "use .Net helper class/service" or anything else? custom component should be fine to unzip and extract pdf files and read CSV? can go with another custom component on send to perform split
    and zip the files.
    Any recommendations?

    Hi,
    You can built custom pipeline component for unzipping, I have wrote an article for it: http://social.technet.microsoft.com/wiki/contents/articles/20640.biztalk-server-2010-processing-zip-message-having-multiple-type-files.aspx
    Also sample is available : http://code.msdn.microsoft.com/windowsdesktop/BizTalk-Server-2010-42a1ae49/view/SourceCode
    I hope it helps !!
    Maheshkumar S Tiwari|User Page|Blog|BizTalk
    Server : How Map Works on Port Level

  • I backed up TBird with Mozbackup, but cannot restore: I unzipped the PCV file but how do I restore my profile from that?

    The unzipped PCV file includes an address file and multiple mail files in plain text.
    What next?

    Why do you say "of course"? You didn't tell us what you had or hadn't done, so someone needs to ask.
    It would seem that mozbackup didn't make a legitimate "zip archive", or is buggy and doesn't recognize a good zipped archive.
    Since you have unzipped it manually, you are now in possession of your old profile, so you could follow the usual steps to reinstate an old profile into a new Thunderbird. Essentially, you copy the contents of the old profile over the contents of the new profile.
    https://support.mozilla.org/en-US/kb/profiles-tb

  • [PowerShell] Ping multiple servers simultaneously with PowerShell: Test-ConnectionAsync (strange problems)

    I am hoping the author of the script "Ping multiple servers simultaneously with PowerShell: Test-ConnectionAsync" can help me.
    I found it at: https://gallery.technet.microsoft.com/scriptcenter/Multithreaded-PowerShell-0bc3f59b
    I am using the version dated: 5/8/2014
    I extraced the entire function from the .psm1 file for use in a script that continuously pings about 100 devices and sends an email when a device has failed three times in a row.  At some point, usually between 15 minutes and several hours, the script
    stops running.  If I break out of it <CTRL>-C, and run a "Get-Job" command, I can see that a job is "stuck" at the "Running" state.  I can even retrieve the data using "Receive-Job" and it looks fine.
     Here is a sample of the Get-Job after the program froze (I changed the Source and Destination to protect the names/IPs)...
    PS C:\Program Files\ServerScripts\DeviceMonitor> Get-Job
    Id     Name            PSJobTypeName   State         HasMoreData     Location             Command
    145678 Job145678       WmiJob          Running       True            .                    Test-Connection
    PS C:\Program Files\ServerScripts\DeviceMonitor> Receive-Job 145678
    Source        Destination     IPV4Address      IPV6Address                              Bytes    Time(ms)
    SERVER1  XX.XXX.XXX.XX   XX.XXX.XXX.XX                                             32       5
    SERVER1  XX.XXX.XXX.XX   XX.XXX.XXX.XX                                             32       5
    SERVER1  XX.XXX.XXX.XX   XX.XXX.XXX.XX                                             32       5
    SERVER1  XX.XXX.XXX.XX   XX.XXX.XXX.XX                                             32       5
    PS C:\Program Files\ServerScripts\DeviceMonitor> Get-Job
    Id     Name            PSJobTypeName   State         HasMoreData     Location             Command
    145678 Job145678       WmiJob          Running       False           .                    Test-Connection
    I tried added some additional output in the function to troubleshoot but I can't seem to find the root cause.  I would be happy if I could remove the "stuck" job after a certain amount time, even though this doesn't get to the root of the
    problem.
    Any assistance would be appreciated.  Even if you could point me in the right direction.
    Thank you.

    Hi,
    Questions for Gallery items should be asked on the QandA tab of the listing, as that is usually the fastest way to contact the script's author:
    https://gallery.technet.microsoft.com/scriptcenter/Multithreaded-PowerShell-0bc3f59b/view/Discussions#content
    Dave does frequent this forum, so you might get a response from him here directly.
    Don't retire TechNet! -
    (Don't give up yet - 13,085+ strong and growing)

  • I have tried a lot to find an app or some way in email to attach multiple of pdf files in one email. I could not find anything that sends multiple pdf file in one email and still keeping the file in simple pdf format for the recipient.

    I have tried a lot to find an app or some way in email to attach multiple of pdf files in one email. I could not find anything that sends multiple pdf file in one email and still keeping the file in simple pdf format for the recipient.

    I am not aware of a way except for photos that allows you to select multiple files in an email. I even checked settings in the Adobe Reader app, and it does not show that ability.

  • How to exreact multiple pdf files from a zip files from application server to presentation server

    Hello exprts,
    I am passing one pdf file and one text file to zip file in apllication server through my custom program and then downloading it using standard function module to my desktop. its working fine. Then I added  another pdf file to my zip file. But only single pdf file is getting download . So can you please help me regardiong this issue? 

    Dear Experts ,
    I finded out the way to extrcat pdf files in presentation server. But now my problem is that I am not able to add multiple pdf files in a zip file. When I am adding new pdf file then older one is not coming in read data set. So please kindly tell me how can I add multiple pdf file in my zip file and again I can get all the pdf files from here.

  • IE running under XP can't handle multiple SWF files, Why?

    I noticed that IE 8 running under Windows XP cannot handle multiple swf files in one page.
    Up to about 10 files is no problem they are loaded and we can play them ( buttons that start a small audio file).
    But more of these files in one page will stop IE.
    Firefox ( 3.6.28) runs them fine.
    And also IE 8 and/or Firefox under Windows 7 handles them perfectly.
    Has anyone any idea what can cause this and how to resolve this?
    Thanks,
    Onno Tomson
    The Netherlands

    Sorry...I still don't get it. What is it about Windows FUS that keeps iTunes from running running the process twice? It can run many other non-Apple windows apps in multiple user sessions (commercial apps, open source apps, audio/video apps, networked apps). I can even run two different virtual machines at the same time under two different user sessions.
    Why can iTunesHelper.exe run twice but iTunes.exe cannot? Why can I run Safari at the same time? Quicktime Player runs fine under multiple user sessions.
    Blaming it on Windows and/or FUS sounds like FUD. Can anyone give a valid technical reason? Semaphores? Mutexes? An admission (and explanation) that the Windows version is purposely crippled?

  • Open Multiple PDF files from Production order/Routing

    Hi Everyone
    We are in ECC 6.0 environment. We have a scenario where multiple documents were attached to single operation and also at multiple operations. But when I was trying to open these PDF documents, only the last file was getting opened and closing the previous file. How can I open multiple PDF files at one time from Production order or Routing?
    Any help is appreciated.
    Regards
    Prasad

    Hi Prasad,
    from DMS standard I regret but such a functionality is not available. In the standard originals can be opened only one after another.
    I think for realising this functionality an individual modificatoin is necessary.
    Best regards,
    Christoph

  • Multiple DB files clean migration (follow up to my decommission question)

    So I have requested help standing up a new environment and phasing out an old one since it was "all messed up" after spending some time digging into it it looks like best practice was followed (which I don't know how I missed this after reading
    through Mastering the fundamentals by Kent Agerlund multiple times). Apparently they suggest you create multiple SQL file based on how many CPU's you have available to help performance. 
    The question I have now is when the backup site task runs it only backs up 1 2GB MDF file and a 11GB LDF file. Does that make sense? It doesn't look like the other SQL files that were created are being used at all? None of the SQL files have not grown past
    the initial size (the first file started at 2GB and is still that size). 
    Assuming everything is working correctly my new plan would be to upgrade the existing setup and do a backup and restore to the new box using the same site code and server name. If I do that will it bring all those other SQL files with it our can I consolidate
    onto 1 file again? I don't think we need to worry about performance as the DB is pretty small and I'm trying to keep things simple. 
    My other choice is I have the new server built with new site code so I could add the first site as a child site and migrate things over? I have multiple DP's out there so I'm not sure best way to handle that. The plan was to blow them away and rebuild brand
    new ones for the new site, but if I can just throw an upgrade on them that should work and be less work. 

    My other choice is I have the new server built with new site code so I could add the first site as a child site and migrate things over?
    That won't work in CM12.
    Just back up the database using SQL and use that for the restore (there's no need for the SMSBackup task in CM12).
    Torsten Meringer | http://www.mssccmfaq.de

Maybe you are looking for

  • Web sphere portlets not working

    i have this provider registered in oracle portal as http://localhost:9080/portal/providers which are hosted on a web sphere application server but when i click on a link rather then going to http://localhost:9080/portal/main.do it is going to http://

  • Maximum hard drive size for upgrading a dv6375ea?

    Hello to all,   My hard drive began to make noises and since it is past warranty, I will upgrade it. When I had bought the laptop I had chatted with a HP personnel on these support pages, and he/she had told me that the maximum size that the bios all

  • Can I get the Apple Color Picker in CS5 Windows?

    HI - I'm a lifetime Mac and long time PShop user transplanted into a Windows shop.  Of all the things that I miss on my new workplace platform, the Apple Color Picker is the one that I encounter most often. Is there a plug-in, an extension, is there

  • How can I keep the name of the user around for each JSP without asking user

    I have a number of JSP pages that I give the user access to once they login successfully. I want to be able to keep the name of the user present on every page without having to ask them for it each time. How can I do this? Currently I have a user obj

  • V.  11 crashing

    After installing v. 11 602, it will not play any video and terminates the program.