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:
awk '{system("mv "$1 " ./"$4)}' sizes.log
The content of sizes.log was many lines in this format:
f122441728.jpg Exif.Photo.PixelXDimension Long 1 4032
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.
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.
Is that assumption correct? Do I have a chance of a recovery with photorec for example?
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..
edit: 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.
identify -format "%f %w\n" *.jpg >> siz.log
awk '{system("mkdir ./"$2"/")}' siz.log
awk '{system("mv "$1 " ./"$2"/")}' siz.log
note the trailing slash, that is what got me into trouble before. I missed it and got no error messages from mv.