title: I lost a lot of files through a batch mv to the same destination. Are my files still on the disk?
body: <p>I was trying to batch move images from a folder to new folders that are named by the image (px) size of the images. I used this command to do that:</p>
  
  <pre><code>awk '{system("mv "$1 " ./"$4)}' sizes.log
  </code></pre>
  
  <p>The content of sizes.log was many lines in this format:</p>
  
  <pre><code>f122441728.jpg        Exif.Photo.PixelXDimension                   Long        1  4032
  </code></pre>
  
  <p>I am now painfully aware of the shortcomings of this method. I didn't test my command and moved many files into the file "1" because column $4 is "1" in all lines of sizes.log.
  I realized something was off and aborted the command, but about 500 pictures were deleted. </p>
  
  <p>I am not sure how mv works but, as far as far as I understand, this happened:
  In each line the file from column $1 got renamed to "1", but the data blocks of the image file remained on the disk.</p>
  
  <p>Is that assumption correct?
  Do I have a chance of a recovery with photorec for example?</p>
  
  <p>I would have to reassemble a RAID in another machine, but that is something I have had luck with before. I was sorting a run of photorec from another mistake..</p>
  
  <p><strong>edit:</strong>
  After I found a backup of my files (yay!) I have revisited the procedure that led me to my mistake and have used these commands to sort my files into folders that are named by the image size of the pictures.</p>
  
  <pre><code>identify -format "%f %w\n" *.jpg &gt;&gt; siz.log
  
  awk '{system("mkdir ./"$2"/")}' siz.log
  
  awk '{system("mv "$1 " ./"$2"/")}' siz.log
  </code></pre>
  
  <p>note the trailing slash, that is what got me into trouble before. I missed it and got no error messages from mv.</p>