{"id":277,"date":"2012-05-27T02:27:58","date_gmt":"2012-05-27T00:27:58","guid":{"rendered":"https:\/\/www.npcglib.org\/~stathis\/blog\/?p=277"},"modified":"2014-07-22T23:50:08","modified_gmt":"2014-07-22T21:50:08","slug":"windows-task-extracting-tar-gz-files-in-one-step-with-7-zip","status":"publish","type":"post","link":"https:\/\/www.npcglib.org\/~stathis\/blog\/2012\/05\/27\/windows-task-extracting-tar-gz-files-in-one-step-with-7-zip\/","title":{"rendered":"windows task: extracting .tar.gz files in one step with 7-zip"},"content":{"rendered":"<p>I noticed that there are people trying to come up with a way to extract .tar.gz files in one go on Windows. For instance, I was reading: <a href=\"http:\/\/superuser.com\/questions\/80019\/how-can-i-unzip-a-tar-gz-in-one-step-using-7-zip\" target=\"_blank\">How can I unzip a .tar.gz in one step (using 7-Zip)?<\/a> While on a unix system this is trivial, with 7-zip on Windows this becomes a two-step process. There are of course a lot of solutions to this on Windows. The way I prefer to do it on Windows 7, is to have a context menu on Windows Explorer, right-click and extract the file in one go.<\/p>\n<p>You can download the Registry file I created right here: <a href=\"\/~stathis\/downloads\/7zip-extract-tar-gz.reg\">7zip-extract-tar-gz.reg<\/a>, use Save Link As to save it as a file, then double-click to import it into your registry: at your own risk of course!<br \/>\nYou will also need to have the 7zip executables in your environment PATH for this to work.<\/p>\n<p>To do this first create the context menu entry:<\/p>\n<ul>\n<li>open the Registry Editor (regedit.exe)<\/li>\n<li>go to <code>HKEY_CURRENT_USER\\Software\\Classes<\/code><\/li>\n<li>create a new key called <code>7-zip.gz<\/code><\/li>\n<li>under <code>7-zip.gz<\/code> create another key called shell<\/li>\n<li>under shell create another key called any name you like, e.g. <code>extract_tar_gz<\/code><\/li>\n<li>provide a value for that last key, which is the text that will appear in the context menu of Windows Explorer when you right-click a .gz file. I named mine <code>Extract .tar.gz<\/code><\/li>\n<li>create another key this time called <code>command<\/code><\/li>\n<li>the value of this key must be (<u>put all text in one line!!<\/u>):\n<pre>\r\ncmd \/c @for %%f in (\"%1\") do ( \r\n     @7z x -y \"%%~ff\" -o\"%%~dpf\" &&  \r\n     @for %%i in (\"%%~nf\") do ( \r\n          @if %%~xi==.tar ( \r\n               @7z x -y \"%%~fi\" -o\"%%~dpi\" && del \"%%~fi\"\r\n          )\r\n     ) \r\n) \r\n&& pause\r\n<\/pre>\n<\/li>\n<\/ul>\n<p>the <code>7-zip.gz<\/code> registry key hierarchy should now look like this:<\/p>\n<div id=\"attachment_1297\" style=\"width: 878px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/www.npcglib.org\/~stathis\/blog\/wp-content\/uploads\/2012\/05\/extract_tar_gz_registry.png\"><img aria-describedby=\"caption-attachment-1297\" src=\"https:\/\/www.npcglib.org\/~stathis\/blog\/wp-content\/uploads\/2012\/05\/extract_tar_gz_registry.png\" alt=\"Registry key hierarchy for the context menu to extract .tar.gz files\" width=\"868\" class=\"size-full wp-image-1297\" srcset=\"https:\/\/www.npcglib.org\/~stathis\/blog\/wp-content\/uploads\/2012\/05\/extract_tar_gz_registry.png 1104w, https:\/\/www.npcglib.org\/~stathis\/blog\/wp-content\/uploads\/2012\/05\/extract_tar_gz_registry-300x37.png 300w, https:\/\/www.npcglib.org\/~stathis\/blog\/wp-content\/uploads\/2012\/05\/extract_tar_gz_registry-1024x128.png 1024w\" sizes=\"(max-width: 1104px) 100vw, 1104px\" \/><\/a><p id=\"caption-attachment-1297\" class=\"wp-caption-text\">Registry key hierarchy for the context menu to extract .tar.gz files<\/p><\/div>\n<p>It is assumed that the command line utility of 7-zip (7z.exe) is available in your <code>PATH<\/code>. If it isn&#8217;t add it.<br \/>\nOf course instead of squeezing the commands of extracting the files one after the other and then deleting the intermediate .tar file, you could write a more elaborate batch file and invoke that to handle the situation and add some error checking too. You could potentially do a similar process for <code>.tar.bz2<\/code> files.<\/p>\n<p>To use it open a Windows Explorer and locate your .tar.gz file, right-click and select the command you added. Mine looks like this:<br \/>\n<div id=\"attachment_291\" style=\"width: 449px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/www.npcglib.org\/~stathis\/blog\/wp-content\/uploads\/2012\/05\/extract-gz-context-menu.png\"><img aria-describedby=\"caption-attachment-291\" loading=\"lazy\" src=\"https:\/\/www.npcglib.org\/~stathis\/blog\/wp-content\/uploads\/2012\/05\/extract-gz-context-menu.png\" alt=\"\" title=\"extract-gz-context-menu\" width=\"439\" height=\"217\" class=\"size-full wp-image-291\" srcset=\"https:\/\/www.npcglib.org\/~stathis\/blog\/wp-content\/uploads\/2012\/05\/extract-gz-context-menu.png 439w, https:\/\/www.npcglib.org\/~stathis\/blog\/wp-content\/uploads\/2012\/05\/extract-gz-context-menu-300x148.png 300w\" sizes=\"(max-width: 439px) 100vw, 439px\" \/><\/a><p id=\"caption-attachment-291\" class=\"wp-caption-text\">Context menu that appears on Windows Explorer.<\/p><\/div><\/p>\n<p>Keep in mind that this command will <u>not<\/u> clutter your context menu, as it will only appear when you right-click a <code>.gz<\/code> file. Also note that the script does some basic checking if the .gz file does have a .tar in it, but don&#8217;t expect it to be of commercial software quality, it&#8217;s just a quick hack!<\/p>\n<p>The command looks cryptic, but the logic is actually extremely simple. Do you want the command explained?<\/p>\n<hr>\n<p>Changelog:<\/p>\n<p>23\/07\/2014 &#8211; Created a .reg file that can be imported into the Windows 7 Registry (use with caution on other OSes)<br \/>\n28\/12\/2013 &#8211; Fixed problem with archives that contained spaces. (thanks to Orinoco for reporting it)<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I noticed that there are people trying to come up with a way to extract .tar.gz files in one go on Windows. For instance, I was reading: How can I unzip a .tar.gz in one step (using 7-Zip)? While on a unix system this is trivial, with 7-zip on Windows this becomes a two-step process. [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[7],"tags":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v17.9 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<meta name=\"description\" content=\"Windows Explorer right click and extract tar.gz files, in one step!\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.npcglib.org\/~stathis\/blog\/2012\/05\/27\/windows-task-extracting-tar-gz-files-in-one-step-with-7-zip\/\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"stathis\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.npcglib.org\/~stathis\/blog\/#website\",\"url\":\"https:\/\/www.npcglib.org\/~stathis\/blog\/\",\"name\":\"sigmoid\",\"description\":\"..oo..oo..oo..oo..oo..oo..\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.npcglib.org\/~stathis\/blog\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/www.npcglib.org\/~stathis\/blog\/2012\/05\/27\/windows-task-extracting-tar-gz-files-in-one-step-with-7-zip\/#primaryimage\",\"inLanguage\":\"en-US\",\"url\":\"https:\/\/www.npcglib.org\/~stathis\/blog\/wp-content\/uploads\/2012\/05\/extract_tar_gz_registry.png\",\"contentUrl\":\"https:\/\/www.npcglib.org\/~stathis\/blog\/wp-content\/uploads\/2012\/05\/extract_tar_gz_registry.png\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.npcglib.org\/~stathis\/blog\/2012\/05\/27\/windows-task-extracting-tar-gz-files-in-one-step-with-7-zip\/#webpage\",\"url\":\"https:\/\/www.npcglib.org\/~stathis\/blog\/2012\/05\/27\/windows-task-extracting-tar-gz-files-in-one-step-with-7-zip\/\",\"name\":\"Windows Explorer context menu to extract .tar.gz files in one step\",\"isPartOf\":{\"@id\":\"https:\/\/www.npcglib.org\/~stathis\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.npcglib.org\/~stathis\/blog\/2012\/05\/27\/windows-task-extracting-tar-gz-files-in-one-step-with-7-zip\/#primaryimage\"},\"datePublished\":\"2012-05-27T00:27:58+00:00\",\"dateModified\":\"2014-07-22T21:50:08+00:00\",\"author\":{\"@id\":\"https:\/\/www.npcglib.org\/~stathis\/blog\/#\/schema\/person\/508363c4ebd1fd6066edf00c94e37e41\"},\"description\":\"Windows Explorer right click and extract tar.gz files, in one step!\",\"breadcrumb\":{\"@id\":\"https:\/\/www.npcglib.org\/~stathis\/blog\/2012\/05\/27\/windows-task-extracting-tar-gz-files-in-one-step-with-7-zip\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.npcglib.org\/~stathis\/blog\/2012\/05\/27\/windows-task-extracting-tar-gz-files-in-one-step-with-7-zip\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.npcglib.org\/~stathis\/blog\/2012\/05\/27\/windows-task-extracting-tar-gz-files-in-one-step-with-7-zip\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.npcglib.org\/~stathis\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"windows task: extracting .tar.gz files in one step with 7-zip\"}]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.npcglib.org\/~stathis\/blog\/#\/schema\/person\/508363c4ebd1fd6066edf00c94e37e41\",\"name\":\"stathis\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/www.npcglib.org\/~stathis\/blog\/#personlogo\",\"inLanguage\":\"en-US\",\"url\":\"http:\/\/2.gravatar.com\/avatar\/214f29f604ec7d8d2f1345c5fa617c09?s=96&d=mm&r=g\",\"contentUrl\":\"http:\/\/2.gravatar.com\/avatar\/214f29f604ec7d8d2f1345c5fa617c09?s=96&d=mm&r=g\",\"caption\":\"stathis\"},\"url\":\"https:\/\/www.npcglib.org\/~stathis\/blog\/author\/stathis\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"description":"Windows Explorer right click and extract tar.gz files, in one step!","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.npcglib.org\/~stathis\/blog\/2012\/05\/27\/windows-task-extracting-tar-gz-files-in-one-step-with-7-zip\/","twitter_misc":{"Written by":"stathis","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebSite","@id":"https:\/\/www.npcglib.org\/~stathis\/blog\/#website","url":"https:\/\/www.npcglib.org\/~stathis\/blog\/","name":"sigmoid","description":"..oo..oo..oo..oo..oo..oo..","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.npcglib.org\/~stathis\/blog\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"ImageObject","@id":"https:\/\/www.npcglib.org\/~stathis\/blog\/2012\/05\/27\/windows-task-extracting-tar-gz-files-in-one-step-with-7-zip\/#primaryimage","inLanguage":"en-US","url":"https:\/\/www.npcglib.org\/~stathis\/blog\/wp-content\/uploads\/2012\/05\/extract_tar_gz_registry.png","contentUrl":"https:\/\/www.npcglib.org\/~stathis\/blog\/wp-content\/uploads\/2012\/05\/extract_tar_gz_registry.png"},{"@type":"WebPage","@id":"https:\/\/www.npcglib.org\/~stathis\/blog\/2012\/05\/27\/windows-task-extracting-tar-gz-files-in-one-step-with-7-zip\/#webpage","url":"https:\/\/www.npcglib.org\/~stathis\/blog\/2012\/05\/27\/windows-task-extracting-tar-gz-files-in-one-step-with-7-zip\/","name":"Windows Explorer context menu to extract .tar.gz files in one step","isPartOf":{"@id":"https:\/\/www.npcglib.org\/~stathis\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.npcglib.org\/~stathis\/blog\/2012\/05\/27\/windows-task-extracting-tar-gz-files-in-one-step-with-7-zip\/#primaryimage"},"datePublished":"2012-05-27T00:27:58+00:00","dateModified":"2014-07-22T21:50:08+00:00","author":{"@id":"https:\/\/www.npcglib.org\/~stathis\/blog\/#\/schema\/person\/508363c4ebd1fd6066edf00c94e37e41"},"description":"Windows Explorer right click and extract tar.gz files, in one step!","breadcrumb":{"@id":"https:\/\/www.npcglib.org\/~stathis\/blog\/2012\/05\/27\/windows-task-extracting-tar-gz-files-in-one-step-with-7-zip\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.npcglib.org\/~stathis\/blog\/2012\/05\/27\/windows-task-extracting-tar-gz-files-in-one-step-with-7-zip\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.npcglib.org\/~stathis\/blog\/2012\/05\/27\/windows-task-extracting-tar-gz-files-in-one-step-with-7-zip\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.npcglib.org\/~stathis\/blog\/"},{"@type":"ListItem","position":2,"name":"windows task: extracting .tar.gz files in one step with 7-zip"}]},{"@type":"Person","@id":"https:\/\/www.npcglib.org\/~stathis\/blog\/#\/schema\/person\/508363c4ebd1fd6066edf00c94e37e41","name":"stathis","image":{"@type":"ImageObject","@id":"https:\/\/www.npcglib.org\/~stathis\/blog\/#personlogo","inLanguage":"en-US","url":"http:\/\/2.gravatar.com\/avatar\/214f29f604ec7d8d2f1345c5fa617c09?s=96&d=mm&r=g","contentUrl":"http:\/\/2.gravatar.com\/avatar\/214f29f604ec7d8d2f1345c5fa617c09?s=96&d=mm&r=g","caption":"stathis"},"url":"https:\/\/www.npcglib.org\/~stathis\/blog\/author\/stathis\/"}]}},"_links":{"self":[{"href":"https:\/\/www.npcglib.org\/~stathis\/blog\/wp-json\/wp\/v2\/posts\/277"}],"collection":[{"href":"https:\/\/www.npcglib.org\/~stathis\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.npcglib.org\/~stathis\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.npcglib.org\/~stathis\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.npcglib.org\/~stathis\/blog\/wp-json\/wp\/v2\/comments?post=277"}],"version-history":[{"count":29,"href":"https:\/\/www.npcglib.org\/~stathis\/blog\/wp-json\/wp\/v2\/posts\/277\/revisions"}],"predecessor-version":[{"id":1354,"href":"https:\/\/www.npcglib.org\/~stathis\/blog\/wp-json\/wp\/v2\/posts\/277\/revisions\/1354"}],"wp:attachment":[{"href":"https:\/\/www.npcglib.org\/~stathis\/blog\/wp-json\/wp\/v2\/media?parent=277"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.npcglib.org\/~stathis\/blog\/wp-json\/wp\/v2\/categories?post=277"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.npcglib.org\/~stathis\/blog\/wp-json\/wp\/v2\/tags?post=277"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}