Page 1 of 2 12 LastLast
  1.    11 Mar 2017 #1
    Join Date : Mar 2015
    Posts : 176
    Win 10 Pro x64

    Issue when extracting multiple files within different folders at once


    So I have a lot of .zips and .rars scattered around one of my hard drives. I wanted to extract all of these to the folders in which they lived in one swift go. So I did a search and selected the .zips to test it out and chose "extract each archive to a separate folder". I used winrar to do this. What happened is archives did NOT all extract to the folder in which they lived. Instead they were ALL extracted to the folder in which the first archive lived. So I was not able to do this extraction of all the archives into their home folder like I liked and ended up having to manually extract one by one while in each archives folder. I also tried to extract with 7zip and had the same result.I'd rather not have to do this with the .rars. Has anyone encountered this issue and know of a fix?
      My ComputerSystem Spec
  2.    12 Mar 2017 #2
    Join Date : Oct 2014
    Posts : 60
    Windows 11

    Huh, you're right. Just tried it with WinRAR's "Extract Here" context menu entry from an Explorer search. It wants to put all the files in the first folder.

    You could do it like this from PowerShell:
    Code:
      Get-ChildItem Z:\YourDir -Include *.zip, *.rar -Recurse | ForEach-Object {& "C:\Program Files\WinRAR\WinRAR.exe" e $_.FullName $_.Directory}
      My ComputerSystem Spec
  3.    12 Mar 2017 #3
    Join Date : Mar 2015
    Posts : 176
    Win 10 Pro x64
    Thread Starter

    Quote Originally Posted by Michael View Post
    Huh, you're right. Just tried it with WinRAR's "Extract Here" context menu entry from an Explorer search. It wants to put all the files in the first folder.

    You could do it like this from PowerShell:
    Code:
      Get-ChildItem Z:\YourDir -Include *.zip, *.rar -Recurse | ForEach-Object {& "C:\Program Files\WinRAR\WinRAR.exe" e $_.FullName $_.Directory}
    Yeah, very weird. I'll give that a go. Thanks.

    Edit: Sweet that worked. Only thing is that it "extracted here" when I was looking for it to "extract to a separate folder". Would I be able to tweak this to do that? Thanks
      My ComputerSystem Spec
  4.    12 Mar 2017 #4
    Join Date : Mar 2015
    Posts : 176
    Win 10 Pro x64
    Thread Starter

    Quote Originally Posted by Michael View Post
    You'd just replace that last $_.Directory part with something like Z:\Unzipped, or if you wanted to file them into folders of the same name as the original archives, you could do something like: Z:\Unzipped\$_.BaseName
    Well I don't want to extract them all to a different location. I want them all to extract to a separate folder of the .zip file's name in the current directory the .zip lives.

    So c:\pictures\cats\catpics1.zip should unzip to c:\pictures\cats\catpics1
    and
    c:\pictures\dogs\dogpics1.zip should unzip to c:\pictures\dogs\dogpics1

    Would the below accomplish that?

    Code:
    Get-ChildItem Z:\YourDir -Include *.zip, *.rar -Recurse | ForEach-Object {& "C:\Program Files\WinRAR\WinRAR.exe" e $_.FullName $_.Directory\$_.BaseName}
      My ComputerSystem Spec
  5.    12 Mar 2017 #5
    Join Date : Oct 2014
    Posts : 60
    Windows 11

    Whoops, I realized we should be using WinRAR's X command instead of E to preserve the archive's internal folder structure. And $_.DirectoryName is what we actually want, plus a bit more punctuation to get the string to behave. So yes, you almost had it.

    This will extract archives to folders of the same name, equivalent to "Extract to Folder" from the context menu:
    Code:
    Get-ChildItem Z:\YourDir -Include *.zip, *.rar -Recurse | ForEach-Object {& "C:\Program Files\WinRAR\WinRAR.exe" x $_.FullName ($_.DirectoryName+'\'+$_.BaseName+'\')}
    Last edited by Michael; 12 Mar 2017 at 04:15.
      My ComputerSystem Spec
  6.    12 Mar 2017 #6
    Join Date : Mar 2015
    Posts : 176
    Win 10 Pro x64
    Thread Starter

    Quote Originally Posted by Michael View Post
    Whoops, I realized we should be using WinRAR's X command instead of E to preserve the archive's internal folder structure. And $_.DirectoryName is what we actually want, plus a bit more punctuation to get the string to behave. So yes, you almost had it.

    This will extract archives to folders of the same name, equivalent to "Extract to Folder" from the context menu:
    Code:
    Get-ChildItem Z:\YourDir -Include *.zip, *.rar -Recurse | ForEach-Object {& "C:\Program Files\WinRAR\WinRAR.exe" x $_.FullName ($_.DirectoryName+'\'+$_.BaseName+'\')}
    Worked like a charm! Thanks for your help.

    Edit: One last thing, I and I'm really not sure if there's a way around this. Is there a way so that it extracts one archive at a time? Right now if I have 20 .zips in a directory it will slowly extract all of them at once, bogging down the machine instead of waiting for the previous one to finish.
    Last edited by bobsagetfullhou; 12 Mar 2017 at 09:31.
      My ComputerSystem Spec
  7.    12 Mar 2017 #7
    Join Date : Oct 2014
    Posts : 60
    Windows 11

    Oh right, hadn't realized because I've been testing with empty files that take a split-second to extract.

    You'll want to add this to the end, before the closing curly bracket:
    Code:
    ; Wait-Process WinRAR
    So like:
    Code:
    Get-ChildItem Z:\YourDir -Include *.zip, *.rar -Recurse | ForEach-Object {& "C:\Program Files\WinRAR\WinRAR.exe" x $_.FullName ($_.DirectoryName+'\'+$_.BaseName+'\'); Wait-Process WinRAR}
      My ComputerSystem Spec
  8.    12 Mar 2017 #8
    Join Date : Mar 2015
    Posts : 176
    Win 10 Pro x64
    Thread Starter

    Quote Originally Posted by Michael View Post
    Oh right, hadn't realized because I've been testing with empty files that take a split-second to extract.

    You'll want to add this to the end, before the closing curly bracket:
    Code:
    ; Wait-Process WinRAR
    So like:
    Code:
    Get-ChildItem Z:\YourDir -Include *.zip, *.rar -Recurse | ForEach-Object {& "C:\Program Files\WinRAR\WinRAR.exe" x $_.FullName ($_.DirectoryName+'\'+$_.BaseName+'\'); Wait-Process WinRAR}
    Thanks for you help sir! Everything working how I'd like it.
      My ComputerSystem Spec
  9.    15 Mar 2017 #9
    Join Date : Mar 2015
    Posts : 176
    Win 10 Pro x64
    Thread Starter

    Quote Originally Posted by Michael View Post
    Oh right, hadn't realized because I've been testing with empty files that take a split-second to extract.

    You'll want to add this to the end, before the closing curly bracket:
    Code:
    ; Wait-Process WinRAR
    So like:
    Code:
    Get-ChildItem Z:\YourDir -Include *.zip, *.rar -Recurse | ForEach-Object {& "C:\Program Files\WinRAR\WinRAR.exe" x $_.FullName ($_.DirectoryName+'\'+$_.BaseName+'\'); Wait-Process WinRAR}
    Hey, hate to be a pest, but had one more little issue. If it's extracting a rarset with multiple rars (Cat pics.part1.rar and cat pics.part2.rar) instead of extracting to a folder named Cat pics, it will extract to a folder named Cat pics.part1. Would there be any way to fix this with the script? Im trying to extract a large amount of files and for it to skip extracting dups which have already been extracted. But if it adds the "part1" then it will create it in a whole new folder and not see it as a dup. Thanks
      My ComputerSystem Spec
  10.    15 Mar 2017 #10
    Join Date : Oct 2014
    Posts : 60
    Windows 11

    If your RARs are fewer than 10 parts (numbered part1, part2, ... as opposed to part01, part02; or part001, part002), you can add:
    Code:
    -Exclude *part[2-9].rar
    As in:
    Code:
    Get-ChildItem Z:\YourDir -Include *.zip, *.rar -Exclude *part[2-9].rar -Recurse | ForEach-Object {& "C:\Program Files\WinRAR\WinRAR.exe" x $_.FullName ($_.DirectoryName+'\'+$_.BaseName+'\'); Wait-Process WinRAR}
    If you have any RARs with more than 9 parts, it'll be a bit more complicated.
      My ComputerSystem Spec

 
Page 1 of 2 12 LastLast


Similar Threads
Thread Forum
Extracting a file off CD
Is there a way to extract a file off win 10 cd? I upgraded to this new version of anniversary build 1607 & then made a DVD off the MCT & need to extract a file called nvstor64.sys as mine older one. It seems this file part of windows boot. I...
General Support
Wierd issue when deleting files/folders
Hey I got a wierd issue when i try to delete anyfile, folder or program that is installed on my windows 10 pc. When i try to delete a text document from my desktop: 1: I mark the document i want to delete and press "DEL". This will make my pc...
General Support
strange issue with hidden folders/files
after online upgrade to win10 from w7 I have my users files on drive D: = a different physical HDD then the C: system files. The drive size is 75GB and it is showing 72GB used. The problem is I can only see 32GB in file explorer under properties....
General Support
Solved Extracting Zip Files
Hi People, Newbie here. As the title suggests I am having a problem unzipping downloaded files on my HP Envy laptop. which has windows 10 version 1511 (build 10586.36) it appears to start the process but just hangs at 99% and will remain there for...
General Support
Moving files into folders puts them under Recent folders.
I have the option "Show recently opened items in Jump Lists on Start or the taskbar" off. However since the last update whenever I either copy or move a file into any folder windows puts that folder under the Recent group in the taskbar. Is there...
Customization
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd
All times are GMT -5. The time now is 11:58.
Find Us
Twitter Facebook Google+ Ten Forums iOS App Ten Forums Android App



Windows 10 Forums