I'm looking for a way to delete the smaller of two files. I have found a way to find the duplicate files in my Movie Library, but now I need to delete the smaller file.
bash - Find All Files with Same Name Regardless of Extension
A few "gotchas" of course... The current output of the list has no extensions.
Eg:
root@fs:ls * | awk '!/.srt/' | sed 's/.\{4\}$//' | sort | uniq -d
Captain Fantastic (2016)
The Hurt Locker (2008)
The Warriors (1979)
I need a way to go back and compare both files with the name Captain Fantastic (2016).*
because the will have different extensions. (All Files are in the same folder)
This is a bit beyond the scope of the question:
I also want to check if FILENAME.srt
file exists, if it does, then I want to just do nothing and save the filename to a log for manual verification. (I need to figure out which file the srt syncs up with).
ls -S
lists from largest to smallest, so I could somehow use that. But I can pretty much guarantee there won't be. Also, I would be fine with deletingALL
smaller files. – FreeSoftwareServers Apr 13 '18 at 05:50