title: recursively rename largest txt file in each directory using find command, Test Case Code included
body: <p>What I am trying to accomplish is renaming the largest file size .txt file in each directory to keep.txt</p>
  <p>here is a block of code you can run to setup a test case:</p>
  <pre><code>mkdir -p './file test/1 first'
  mkdir -p './file test/2 second yay'
  echo 'other file' &gt; './file test/1 first/1other file.nfo'
  echo 'smallest file' &gt; './file test/1 first/1smallest file.txt'
  echo 'this is a medium sized file' &gt; './file test/1 first/1medium file.txt'
  echo 'this is the very largest file of all the files' &gt; './file test/1 first/1keep largest file.txt'
  echo 'other file in the folder thats even larger than everything' &gt; './file test/2 second yay/2other file.nfo'
  echo 'smallest file' &gt; './file test/2 second yay/2smallest file.txt'
  echo 'this is the very largest file of all the files' &gt; './file test/2 second yay/2keep largest file.txt'
  cd 'file test'
  </code></pre>
  <p>output should look like this:</p>
  <pre><code>tree -L 9
  .
  ├── 1 first
  │   ├── 1keep largest file.txt
  │   ├── 1medium file.txt
  │   ├── 1other file.nfo
  │   └── 1smallest file.txt
  └── 2 second yay
      ├── 2keep largest file.txt
      ├── 2other file.nfo
      └── 2smallest file.txt
  </code></pre>
  <p>This command that I have put together seems to return just the largest txt files, but it does it multiple times, which seems to be part of the problem:</p>
  <pre><code>find . -type f -execdir sh -c 'ls -S1 -d &quot;$PWD/&quot;* | grep txt | head -n 1' \;
  </code></pre>
  <p>This is what I had in mind for renaming but it does not do what I expected and I cannot figure out why:</p>
  <pre><code>find . -type f -execdir sh -c 'ls -S1 -d &quot;$PWD/&quot;* | grep txt | head -n 1 | mv &quot;{}&quot; keep.txt' \;
  </code></pre>