Tuesday, August 11, 2015

windows - Batch file to delete all but largest file in a directory

I have a very large directory of files, each with it'd own subdirectory. In those subdirectories are videos of various qualities (1080p, 720p... etc). I only want to keep the video of the highest quality (therefore the largest size). Is there a way to do this via command-line or batch file?



Parent_directory


- Video_A
-- Video_A_1080p
--video_A_720p

-Video_B
-- Video_B_1080p
--video_B_720p
-- Video_B_480p



Note that the name of the videos do not necessarily have the resolutions in the file name. I'm just illustrating the directory structure.



The result should be:



Parent_directory

- Video_A
-- Video_A_1080p


-Video_B
-- Video_B_1080p

No comments:

Post a Comment

linux - How to SSH to ec2 instance in VPC private subnet via NAT server

I have created a VPC in aws with a public subnet and a private subnet. The private subnet does not have direct access to external network. S...