Help: How to run a windows script recursively against each file down a directory tree

agentrfr

Executive Member
Joined
Jul 8, 2008
Messages
5,303
So I have a tonne of TV shows I want to re-encode. The trouble is that they are sorted Name/Season/Episode mostly as .mkv, .mp4 and .avi files. Like, 4TB worth.

I want to run a handbrake CLI script to each file recursively to re-encode each file to an x265 10-bit mkv. I have the individual arguments for handbrake's CLI, but I need a batch script to run down a directory tree and input source and destination filenames into the arguments I throw at handbrake.

I also need it to only apply the script to files that have an .mkv, .mp4 or .avi extension, and DOES NOT contain "x265" or "HEVC" or "H265" in the filename (otherwise this exercise would be pointless, and if the machine crashes it can continue where it stopped and restart the file it used to be on)

Finally, I need to delete the old file once each new file has been made

Now I may have been able to figure it out in a linux shell, but tbh Window's cmd structure confuses me and I have had exactly 0 experience with it before...

Yes I know it will literally take a couple months to do the encode.

Why Windows (10)? The media server machine is Windows because reasons

Thank you to anyone who can help :D
 
Top