The Power of the Shell

Super boring post today.  Sometimes I just put stuff up so I can look back at it later when I’m thinking “I know I did this once, how did I do that?”, and today is one of those posts.

If you’ve ever been bored enough to dig into the archives here, you’ll find an awful lot of ranting about video conversion.  My wife and I used to buy a LOT of movies, and I eventually got tired of having a house decorated in DVD spines, so I spent a few years converting all of the movies into video files that could be imported into iTunes and played on the living room TV using an AppleTV.

I started this in, oh, 2009 or so? And then I finished it almost exactly a year ago.


I didn’t really understand what “metadata” was for the first few years.  Specifically, I didn’t understand video types. (And, to be fair, there’s not a ton of resources out there for people trying to do what I was doing, so I don’t feel too bad about this.)

So what I would do is convert a DVD into an iTunes-compatible m4v file, drop it into iTunes, iTunes would import it as a “Home Movie” and then I would drag it over into Movies or Television, which was great except that every time I tried to import the files into a different copy of iTunes they would wind up in Home Movies again.

Around mid-2013, I figured out how to use mp4v2 to write video types to the m4v files, which meant that I could hard-code “I am a movie” or “I am a TV show” into the files themselves, meaning that iTunes could import them without extra hand holding.

If you want to get mp4v2 on your Mac, by the way, it’s pretty simple.  You need to install the brew package manager:

ruby -e “$(curl -fsSL”

And then just execute:

brew install mp4v2

This was great!  But it meant that I had thousands of video files from before I figured this out, so they didn’t have proper metadata.  Going back to fix them all would have taken a lot of work, so I decided to deal with it.

Years passed, and I got tired of dealing with it.

So here’s my solution, convoluted as it may be.  Hopefully this will come in handy to someone – if not, well, it’s mostly for me to use as reference in the future.

First I figured out when the break was between properly tagged and improperly tagged files.  It turned out to be sometime in June, 2013, so I needed a way to find every file from before then.

My server is a Mac, so I could use the “find” terminal command to find all files older than another file.

Step one: Make a file that I could use as a reference for find.

Step two: Using this file, get a list of all files with either mp4 or m4v extensions that are older than June 1 of 2013.  This actually gets all files with an extension starting with m, so it picks up mp3 etc.  Not hard to filter those out tho.

Side note: You can’t run this “find” command from inside a folder with a dash in the name, you get an error.  Very annoying.

So now I have a list of files, one per line, with full path.  Looks rather like this:

And I can feed every file in the list through mp4tags like so:

And the result is thousands of correctly-tagged video files with minimal effort on my part.

One small annoyance down. 🙂


This entry was posted in video encoding. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.