Several years ago, when DivX was the big thing, I ripped my DVD library to DivX/mp3 .avi's, but I've realized these are severely lacking as I can now crank up the bitrate with H.264/AAC .mp4's for high quality videos. Since disk space keeps getting cheaper and cheaper, I no longer even care how big the files get. Anyway, the point is, I've been ripping/encoding these movies as fast as possible into the same directory that all my other videos reside in, resulting in many duplicate files where one ends in .avi and the other ends in .mp4. I thought to myself that there must be a way to filter these out and after some fiddling I managed to produce a one-liner to do it. Here's what I came up with, but I'd love to know if anyone else has come up with a more efficient solution.
find . -type f -print0 | xargs -0 -I{} basename {} .avi | tr '\n' '\0' | xargs -0 -I{} basename {} .mp4 | sort | uniq -dIf the 'basename' command could take multiple arguments and remove multiple suffixes simultaneously, that would remove both 'xargs' command and the 'tr' command, but AFAIK it doesn't. Anybody know if it's possible to force xargs to do print0 like find does so I could eliminate the tr comman? Oh, and the sort isn't really necessary, but it was helpful as I was composing my pipes.
No comments:
Post a Comment