These are my 5 cent to this issue: I created following script to unpack all .7z and all .zip files recursively in my folder structure.
Might not be required by you - so you can just drop those lines if you like:
- Because I plan to remove all .7z and .zip files after extraction, I created a cleanup.ps1 file (I didn't deleted the archives immediately for safety reasons).
- In case of any extraction errors, I've put the extraction commands into the file ExecUnpack.ps1 to be able to extract single archive again
del "Cleanup.ps1";
del "ExecUnpack.ps1";
del "ExecUnpack.cmd";
get-childitem . -recurse -include @("*.7z","*.zip") | foreach {
"""C:\Program Files\7-Zip\7z.exe"" x ""$($_.FullName)"" -y -o""$($_.FullName.Replace(" .7z", "\").Replace(".7z", "\").Replace(" .zip", "\").Replace(".zip", "\"))""" | Out-File -Append "ExecUnpack.ps1"
"""C:\Program Files\7-Zip\7z.exe"" x ""$($_.FullName)"" -y -o""$($_.FullName.Replace(" .7z", "\").Replace(".7z", "\").Replace(" .zip", "\").Replace(".zip", "\"))""" | Out-File -Append "ExecUnpack.cmd"
$proc=[System.Diagnostics.Process]::Start("C:\Program Files\7-Zip\7z.exe", "x ""$($_.FullName)"" -y -o""$($_.FullName.Replace(" .7z", "\").Replace(".7z", "\").Replace(" .zip", "\").Replace(".zip", "\"))""");
$proc.WaitForExit();
echo "ExitCode=$($proc.ExitCode.ToString()) - $($_.FullName)";
"#ExitCode=$($proc.ExitCode.ToString()) - $($_.FullName)" | Out-File -Append "Cleanup.ps1";
"del ""$($_.FullName)""" | Out-File -Append "Cleanup.ps1";
}
Where this is the main part:
get-childitem . -recurse -include @("*.7z","*.zip") | foreach {
$proc=[System.Diagnostics.Process]::Start("C:\Program Files\7-Zip\7z.exe", "x ""$($_.FullName)"" -y -o""$($_.FullName.Replace(" .7z", "\").Replace(".7z", "\").Replace(" .zip", "\").Replace(".zip", "\"))""");
$proc.WaitForExit();
echo "ExitCode=$($proc.ExitCode.ToString()) - $($_.FullName)";
}
To clarfiy. Do you have archives with other archives in them, or do you have a set of folders that all have .tar and .tgz files in them? – soandos – 2012-02-19T16:44:13.723
@soandos "archives with other archives in them ..." – suffa – 2012-02-19T16:51:54.530