{"id":13,"date":"2012-11-02T13:54:22","date_gmt":"2012-11-02T13:54:22","guid":{"rendered":"http:\/\/simon.aldrich.eu\/blog\/?p=13"},"modified":"2024-11-25T14:12:17","modified_gmt":"2024-11-25T14:12:17","slug":"par2cmdline-list","status":"publish","type":"post","link":"https:\/\/simon.aldrich.cc\/blog\/2012\/11\/par2cmdline-list\/","title":{"rendered":"Listing recovery and source files using par2cmdline"},"content":{"rendered":"<p>I use the <a href=\"http:\/\/parchive.sourceforge.net\/\" target=\"_blank\" rel=\"noopener\">parchive<\/a> command-line utility <code>par2<\/code> quite a lot. In order to improve its scriptability I found that I needed to have the ability to list the recovery (<code>*.par2<\/code>) and source files (the files verified or repaired using the recovery data) associated with a master PAR2 file.<\/p>\n<p>Admittedly I could have scraped the output from <code>par2 -r &lt;somefile.par2&gt;<\/code> but as it does some progress-percentage type output to the console I thought it might be cleaner to patch the <code>par2<\/code> command to add a <code>-list<\/code> option.<\/p>\n<p>Here&#8217;s how to download, <a href=\"http:\/\/simon.aldrich.cc\/download\/par2cmdline\/par2cmdline-0.4-list.patch\" target=\"_blank\" rel=\"noopener\">patch<\/a> &amp; compile the <a href=\"http:\/\/sourceforge.net\/projects\/parchive\/files\/par2cmdline\/\" target=\"_blank\" rel=\"noopener\">par2cmdline<\/a> v0.4 package to get these changes for yourself. These instructions are specifically for Ubuntu 10.04 (Lucid Lynx) but will probably work on any recent(ish) Ubuntu (or indeed Debian) install.<\/p>\n<p><em>Optional step; if you&#8217;ve already installed par2cmdline via apt-get you&#8217;ll probably want to remove it with:<\/em><\/p>\n<pre>sudo apt-get remove par2<\/pre>\n<ol>\n<li>Download the source of par2cmdline v0.4 from <a href=\"http:\/\/sourceforge.net\/projects\/parchive\/files\/par2cmdline\/0.4\/\" target=\"_blank\" rel=\"noopener\">here<\/a> (hint: you want <code>par2cmdline-0.4.tar.gz<\/code>).<\/li>\n<li>Untar the archive, this will create a par2cmdline-0.4 directory with the source in.<\/li>\n<li>If you&#8217;ve got gcc version 4 on your machine (you probably have) you&#8217;ll need to apply <a href=\"http:\/\/sources.gentoo.org\/cgi-bin\/viewvc.cgi\/gentoo-x86\/app-arch\/par2cmdline\/files\/par2cmdline-0.4-gcc4.patch\" target=\"_blank\" rel=\"noopener\">this patch<\/a> to the source directory.<\/li>\n<li>Download and apply <a href=\"http:\/\/simon.aldrich.cc\/download\/par2cmdline\/par2cmdline-0.4-list.patch\" target=\"_blank\" rel=\"noopener\" data-wplink-edit=\"true\">my patch<\/a> to the source directory.<\/li>\n<li>Configure, compile and install.<\/li>\n<\/ol>\n<p>Or, if you&#8217;re too busy and|or lazy to follow that, just paste the following into your console:<\/p>\n<pre>wget -O \"par2cmdline-0.4.tar.gz\" \"http:\/\/downloads.sourceforge.net\/project\/parchive\/par2cmdline\/0.4\/par2cmdline-0.4.tar.gz?r=&amp;ts=1351786076&amp;use_mirror=switch\"\ntar -xvzf par2cmdline-0.4.tar.gz\nwget \"http:\/\/sources.gentoo.org\/cgi-bin\/viewvc.cgi\/gentoo-x86\/app-arch\/par2cmdline\/files\/par2cmdline-0.4-gcc4.patch\"\npatch -p0 &lt; par2cmdline-0.4-gcc4.patch\nwget \"http:\/\/simon.aldrich.cc\/download\/par2cmdline\/par2cmdline-0.4-list.patch\"\npatch -p0 &lt; par2cmdline-0.4-list.patch\ncd par2cmdline-0.4\/\n.\/configure\nmake\nsudo make install<\/pre>\n<p>If all goes well you&#8217;ll end up with a <code>par2<\/code> command with the following new options:<\/p>\n<pre>Usage:\n\n  par2 c(reate) [options]  [files] : Create PAR2 files\n  par2 v(erify) [options]  [files] : Verify files using PAR2 file\n  par2 r(epair) [options]  [files] : Repair files using PAR2 files\n  <strong>par2 l(ist)   [options]  [files] : List files using PAR2 files<\/strong>\n\nYou may also leave out the \"c\", \"v\", and \"r\" commands by using \"parcreate\",\n\"par2verify\", or \"par2repair\" instead.\n\nOptions:\n\n  -b  : Set the Block-Count\n  -s  : Set the Block-Size (Don't use both -b and -s)\n  -r  : Level of Redundancy (%%)\n  -c  : Recovery block count (Don't use both -r and -c)\n  -f  : First Recovery-Block-Number\n  -u     : Uniform recovery file sizes\n  -l     : Limit size of recovery files (Don't use both -u and -l)\n  -n  : Number of recovery files (Don't use both -n and -l)\n  -m  : Memory (in MB) to use\n  -v [-v]: Be more verbose\n  -q [-q]: Be more quiet (-q -q gives silence)\n<strong>  -e     : List only recovery files\n  -o     : List only source files<\/strong>\n  --     : Treat all remaining CommandLine as filenames\n<\/pre>\n<p>The <code>-l<\/code> command will by default list both the recovery &amp; source files. Use the <code>-e<\/code> and <code>-o<\/code> options to restrict listing to one or the other of these file types.<\/p>\n<p>By my own admission this patch is pretty rough and ready (it doesn&#8217;t handle PAR v1 files for example) but I hope it&#8217;s of use to someone.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I use the parchive command-line utility par2 quite a lot. In order to improve its scriptability I found that I needed to have the ability to list the recovery (*.par2) and source files (the files verified or repaired using the recovery data) associated with a master PAR2 file. Admittedly I could have scraped the output [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[7,5,6],"tags":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p2Rw4E-d","jetpack_sharing_enabled":true,"jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/simon.aldrich.cc\/blog\/wp-json\/wp\/v2\/posts\/13"}],"collection":[{"href":"https:\/\/simon.aldrich.cc\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/simon.aldrich.cc\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/simon.aldrich.cc\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/simon.aldrich.cc\/blog\/wp-json\/wp\/v2\/comments?post=13"}],"version-history":[{"count":18,"href":"https:\/\/simon.aldrich.cc\/blog\/wp-json\/wp\/v2\/posts\/13\/revisions"}],"predecessor-version":[{"id":385,"href":"https:\/\/simon.aldrich.cc\/blog\/wp-json\/wp\/v2\/posts\/13\/revisions\/385"}],"wp:attachment":[{"href":"https:\/\/simon.aldrich.cc\/blog\/wp-json\/wp\/v2\/media?parent=13"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/simon.aldrich.cc\/blog\/wp-json\/wp\/v2\/categories?post=13"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/simon.aldrich.cc\/blog\/wp-json\/wp\/v2\/tags?post=13"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}