<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.vifm.info/index.php?action=history&amp;feed=atom&amp;title=How_to_extract_files_from_archives_efficiently</id>
	<title>How to extract files from archives efficiently - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.vifm.info/index.php?action=history&amp;feed=atom&amp;title=How_to_extract_files_from_archives_efficiently"/>
	<link rel="alternate" type="text/html" href="https://wiki.vifm.info/index.php?title=How_to_extract_files_from_archives_efficiently&amp;action=history"/>
	<updated>2026-08-25T07:40:23Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.35.1</generator>
	<entry>
		<id>https://wiki.vifm.info/index.php?title=How_to_extract_files_from_archives_efficiently&amp;diff=420&amp;oldid=prev</id>
		<title>Xaizek: /* Sources */ Fix issue number</title>
		<link rel="alternate" type="text/html" href="https://wiki.vifm.info/index.php?title=How_to_extract_files_from_archives_efficiently&amp;diff=420&amp;oldid=prev"/>
		<updated>2017-09-09T18:16:45Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Sources: &lt;/span&gt; Fix issue number&lt;/span&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left diff-editfont-monospace&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 18:16, 9 September 2017&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l77&quot; &gt;Line 77:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 77:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==== Sources ====&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==== Sources ====&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[https://github.com/vifm/vifm/issues/92 Issue #&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;71 &lt;/del&gt;on GitHub]&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[https://github.com/vifm/vifm/issues/92 Issue #&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;92 &lt;/ins&gt;on GitHub]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Category:HOWTO]]&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Category:HOWTO]]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Xaizek</name></author>
	</entry>
	<entry>
		<id>https://wiki.vifm.info/index.php?title=How_to_extract_files_from_archives_efficiently&amp;diff=418&amp;oldid=prev</id>
		<title>Xaizek: Initial version of the page</title>
		<link rel="alternate" type="text/html" href="https://wiki.vifm.info/index.php?title=How_to_extract_files_from_archives_efficiently&amp;diff=418&amp;oldid=prev"/>
		<updated>2017-09-09T18:13:55Z</updated>

		<summary type="html">&lt;p&gt;Initial version of the page&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==== Performance of FUSE mounts ====&lt;br /&gt;
&lt;br /&gt;
Since FUSE file systems can be used with vifm to browse archives and one of the most common task with an archive is extraction of files it contains, it's natural to use copy operation to do that in vifm. Unfortunately there are some issues with performance, which make this significantly slower than it should be. This doesn't seem to be an artifact of FUSE architecture, but rather unoptimized implementation of FUSE mounters. Copying is an I/O intensive operation and vifm sends many requests and because FUSE mounters don't seem to cache even path resolution each request ends up taking a lot of time (relative to time necessary to transfer data itself).&lt;br /&gt;
&lt;br /&gt;
As a workaround this page presents a script, which can be invoked from vifm to extract files from an archive by using 7z and without use of FUSE.&lt;br /&gt;
&lt;br /&gt;
==== Warning ====&lt;br /&gt;
&lt;br /&gt;
The script wasn't thoroughly tested, so check that it works correctly before relying on it.&lt;br /&gt;
&lt;br /&gt;
==== Script ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
#!/usr/bin/bash&lt;br /&gt;
&lt;br /&gt;
if [ -z &amp;quot;$VIFM_FUSE_FILE&amp;quot; ]; then&lt;br /&gt;
    echo &amp;quot;error: this command is meant to be run inside vifm FUSE mount&amp;quot;&lt;br /&gt;
    exit 1&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
archive=&amp;quot;$VIFM_FUSE_FILE&amp;quot;&lt;br /&gt;
filename=&amp;quot;${archive##*/}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
#Because 7z can't extract these files in one call:&lt;br /&gt;
doubleExtraction=0&lt;br /&gt;
if [[ $filename =~ ^.*(tar\.gz|tar\.bz2)$ ]] ;&lt;br /&gt;
then&lt;br /&gt;
    doubleExtraction=1&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
fusehome=&amp;quot;$1&amp;quot;&lt;br /&gt;
shift&lt;br /&gt;
destination=&amp;quot;$1&amp;quot;&lt;br /&gt;
shift&lt;br /&gt;
&lt;br /&gt;
tempDest=`mktemp -d`&lt;br /&gt;
&lt;br /&gt;
files=&lt;br /&gt;
for f; do&lt;br /&gt;
    # obtain relative path inside archive&lt;br /&gt;
    f=&amp;quot;${f#$fusehome}&amp;quot;&lt;br /&gt;
    f=&amp;quot;${f#/}&amp;quot;&lt;br /&gt;
    f=&amp;quot;${f#*/}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
    files=( ${files[@]} &amp;quot;$f&amp;quot; )&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
firstFile=${files[@]:0:1}&lt;br /&gt;
IFS='/' read -ra ADDR &amp;lt;&amp;lt;&amp;lt; $firstFile&lt;br /&gt;
unset ADDR[${#ADDR[@]}-1]&lt;br /&gt;
&lt;br /&gt;
movePath=$tempDest/&lt;br /&gt;
for i in &amp;quot;${ADDR[@]}&amp;quot;; do&lt;br /&gt;
    movePath=$movePath$i/&lt;br /&gt;
done&lt;br /&gt;
movePath=$movePath*&lt;br /&gt;
&lt;br /&gt;
if [[ $doubleExtraction = 1 ]]; then&lt;br /&gt;
    exec 7z x -so &amp;quot;$archive&amp;quot; | 7z x -si -ttar -o$tempDest &amp;quot;${files[@]}&amp;quot; &amp;gt; /dev/null 2&amp;gt;&amp;amp;1 &amp;amp;&amp;amp; mv -i $movePath $destination &amp;amp;&amp;amp; rm -r $tempDest&lt;br /&gt;
else&lt;br /&gt;
    exec 7z x -o$tempDest &amp;quot;$archive&amp;quot; &amp;quot;${files[@]}&amp;quot; &amp;gt; /dev/null 2&amp;gt;&amp;amp;1 &amp;amp;&amp;amp; mv -i $movePath $destination &amp;amp;&amp;amp; rm -r $tempDest&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== vifmrc part ====&lt;br /&gt;
&lt;br /&gt;
Assuming that the script is called &amp;lt;code&amp;gt;extract-files&amp;lt;/code&amp;gt; and is somewhere in &amp;lt;code&amp;gt;$PATH&amp;lt;/code&amp;gt;, the command to add to &amp;lt;code&amp;gt;vifmrc&amp;lt;/code&amp;gt; is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;vim&amp;quot;&amp;gt;&lt;br /&gt;
command! extractfiles :execute '!%%n extract-files' &amp;amp;fusehome expand('%%D') expand('%%f:p')&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== How to use ====&lt;br /&gt;
&lt;br /&gt;
When inside FUSE mounted archive, select files you want to extract into current directory of the inactive pane and run &amp;lt;code&amp;gt;:extractfiles&amp;lt;/code&amp;gt; command.&lt;br /&gt;
&lt;br /&gt;
==== Sources ====&lt;br /&gt;
&lt;br /&gt;
[https://github.com/vifm/vifm/issues/92 Issue #71 on GitHub]&lt;br /&gt;
&lt;br /&gt;
[[Category:HOWTO]]&lt;/div&gt;</summary>
		<author><name>Xaizek</name></author>
	</entry>
</feed>