r/scripting • u/kn00tcn • Jun 17 '18
[bash/python/batch/powershell/or any comparison app] i have pairs of files using the same name with different extensions, would like to batch delete the larger file per pair
i have a set of jpgs & pngs where they're in pairs with the same name, how do i batch delete the larger of the two?
sometimes file1.png is larger than file1.jpg, but other times file2.png is smaller than file2.jpg
(yes jpg is lossy, but perceptually great at 97% 4:4:4 for complex images at a nicely smaller size than png, but pixelated games or few color ones end up increasing the file size over png)
3
Upvotes
4
u/Ta11ow Jun 17 '18 edited Jun 18 '18
Something like that, anyway. If you want a super short version:
Remove
-Whatifto execute the action for real once you're happy with the results.2
u/[deleted] Jun 17 '18 edited Jun 17 '18
Batch (if the filename does not contain exclamation marks):
Remove
pauseandechoif the output looks right.FTP is difficult with batch/ftp.exe alone.
2
u/Pyprohly Jun 18 '18 edited Jun 18 '18
Bash. Need to use
stat -f%zif on macOS1
u/kn00tcn Jun 17 '18
not sure if relevant, the two types could be put in separate folders with extensions removed if that makes comparisons easier (it does for comparison apps) ... then a crazy idea is to use an ftp client set to 'overwrite if destination is larger' to batch transfer once in each way