<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: jjtriff</title>
    <description>The latest articles on DEV Community by jjtriff (@jjtriff).</description>
    <link>https://dev.to/jjtriff</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F87731%2F0fd0a313-7268-4949-b7c4-20b85f47efb7.jpg</url>
      <title>DEV Community: jjtriff</title>
      <link>https://dev.to/jjtriff</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/jjtriff"/>
    <language>en</language>
    <item>
      <title>Comparing files by content in Android</title>
      <dc:creator>jjtriff</dc:creator>
      <pubDate>Sat, 10 Aug 2019 22:31:32 +0000</pubDate>
      <link>https://dev.to/jjtriff/comparing-files-by-content-in-android-4aoc</link>
      <guid>https://dev.to/jjtriff/comparing-files-by-content-in-android-4aoc</guid>
      <description>&lt;p&gt;This is the story of a need:&lt;/p&gt;

&lt;p&gt;I had a simple problem, a lot of files (not images) that looked the same and needed to be sure I wasn't going to loose anything if I deleted them.&lt;/p&gt;

&lt;p&gt;I use Linux for several years now, but when I'm on Windows I never hang around without using &lt;a href="https://www.ghisler.com/" rel="noopener noreferrer"&gt;Total Commander&lt;/a&gt;, a great side by side FS explorer tool. Is full of useful stuff. One of them is &lt;code&gt;Compare by content&lt;/code&gt;. I'll compare 2 files and state they are identical or show the diff output on a special interface for that.&lt;/p&gt;

&lt;p&gt;On Android, gladly, we have Total Commander as well 😄 . Is a must have, seriously. But is now as packed as the original version. Anyway, is powerfull enough to solve my dilema.&lt;/p&gt;

&lt;h2&gt;
  
  
  The dilema: bunch of unknown files that looked the same
&lt;/h2&gt;

&lt;p&gt;I was browsing and doing some cleaning in the internal when I found this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F9gxlhshbs4i8lt7k8qw5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F9gxlhshbs4i8lt7k8qw5.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A lot of files that looked the same, judging by their size. But how to be sure they were the same.&lt;/p&gt;

&lt;p&gt;If I were in Windows I'll had the tools; If I were on Linux, I would have &lt;code&gt;diff&lt;/code&gt;, but I'm on Android... wait... Isn't Android a form of Linux?&lt;/p&gt;

&lt;h2&gt;
  
  
  Diff on Android, which is a sort of Linux (awwwwww, so cool!)
&lt;/h2&gt;

&lt;p&gt;So I went to my trusted &lt;a href="https://play.google.com/store/apps/details?id=jackpal.androidterm&amp;amp;hl=en_US" rel="noopener noreferrer"&gt;Terminal app&lt;/a&gt; and issue the command:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ diff
See diff --help
diff: Need 2 arguments
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Wow, there it is. So, just need to use this to compare the files and get the results. But there are a few of them.&lt;/p&gt;

&lt;h2&gt;
  
  
  Total Commander to the rescue!
&lt;/h2&gt;

&lt;p&gt;Total Commander has the capability of adding buttons to its toolbar (you can see it at the bottom of the image). Pressing the &lt;code&gt;+&lt;/code&gt; sign you'll get a dialog like the next one, where you'll press the &lt;code&gt;Function type:&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F1hhf0n6qtbg11nkqerk4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F1hhf0n6qtbg11nkqerk4.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Of many things you can choose there is a choice to pass arguments to a command. Selecting &lt;code&gt;Send shell command&lt;/code&gt;:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F02qi1ymx4586htbsiiby.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F02qi1ymx4586htbsiiby.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once there is time to tweak on the &lt;code&gt;Parameters:&lt;/code&gt; field. If you hit the &lt;code&gt;?&lt;/code&gt; button you'll find the explanation, but to resume: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The field is a multiline field: one parameter per line&lt;/li&gt;
&lt;li&gt;If the first parameter is an &lt;code&gt;*&lt;/code&gt; it will output the results in a dialog that can be copied to clipboard.&lt;/li&gt;
&lt;li&gt;Using &lt;code&gt;%S&lt;/code&gt; will include the names of selected files in parameter line&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So, knowing this the &lt;code&gt;Parameteres&lt;/code&gt; field goes like this:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;*
diff %S
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fp67e3hcf4mc56fj08bu9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fp67e3hcf4mc56fj08bu9.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So, lets select 2 obviusly different files and try it:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Foc6s79l7d9xu39fb5a1l.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Foc6s79l7d9xu39fb5a1l.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The result:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Frkwhuk448g3900ei6gv9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Frkwhuk448g3900ei6gv9.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is just GREAT!&lt;/p&gt;

&lt;h2&gt;
  
  
  The result on equal files
&lt;/h2&gt;

&lt;p&gt;Now let's go for the similar files:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F74szjz5mnjbfiaqtnjct.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F74szjz5mnjbfiaqtnjct.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now pay attention because the result will be showed on screen for a short period of time and is:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fkk1egldq0dez1do1vew6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fkk1egldq0dez1do1vew6.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Wow, you were lucky to be looking at an static image, otherwise you'll had miss it 😆.&lt;/p&gt;

&lt;p&gt;In this case when files are identical the output of the &lt;code&gt;diff&lt;/code&gt; command is &lt;em&gt;null, nada, zero&lt;/em&gt;. You get me? That's why it prints nothing to a dialog, just the &lt;code&gt;Function succeeded!&lt;/code&gt; overlay message.&lt;/p&gt;

&lt;p&gt;Well, that's about it. Be carefull when comparing coding files, because the whole diff output will be on the dialog, and you know it can get long.&lt;/p&gt;

&lt;p&gt;If you like this post hit the &lt;em&gt;like&lt;/em&gt; or &lt;em&gt;heart&lt;/em&gt; or &lt;em&gt;you know&lt;/em&gt; button. Thank you all!&lt;/p&gt;

</description>
      <category>totalcommander</category>
      <category>diff</category>
      <category>android</category>
    </item>
  </channel>
</rss>
