VideoHelp Forum
+ Reply to Thread
Results 1 to 7 of 7
Thread
  1. Hey all,

    So, what I have here is, 71 small mkv files, that I split from 1 large mkv file (a bunch of Mr. Magoo cartoons, all in 1 file actually ), using ToolNix's splitting-at-chapters function. So now the files are all named something like title00-1(incremented number).mkv. What I'm wanting to do now is automate the renaming of each file to match the chapter title (which is the episode name itself) contained within each individual mkv file. I should also note that the way ToolNix did the splitting, often-times each file will contain 2 chapters in it, so I always want to use the first chapter as the file name.

    Does anyone know of a way to do this? I've done a bit of Google-Fu, without much luck so far.
    Quote Quote  
  2. Member
    Join Date
    Aug 2010
    Location
    San Francisco, California
    Search PM
    I would use FFprobe or maybe Exiftool in a batch to extract metadata to a file, then parse the file to find the (first) chapter title, then rename the MKV file. There are also some renaming GUIs like Advanced Renamer that can probably do it, but I'm not familiar with them.
    Quote Quote  
  3. Same answer as I gave to your identical post over at doom9.org:

    Bulk Rename Utility

    It can do everything you want, and more. I've used it for years. For truly advanced renaming, you can use the built-in "regular expression" capability, although you will need to learn a little programming to make that work. You'll have to first extract the title from the MKV file, but once you have those names, you can use this tool.

    Since the actual video is nothing more than Mr. Magoo cartoons, you could also just find an episode list somewhere online, and use the episode titles you find there. Hopefully the episodes were lined up in the original MKV file in some sort of chronological order.
    Quote Quote  
  4. Member
    Join Date
    Aug 2010
    Location
    San Francisco, California
    Search PM
    Here is a batch file to do the job with FFprobe. This assumes that your working directory is where the MKVs are stored and that ffprobe.exe is in your search path.

    Code:
    @echo off
    for %%F in (*.mkv) do (
    	ffprobe -loglevel quiet -show_chapters %%F > chapters.txt
    	call :Rename
    )
    goto :eof
    			
    :Rename
    for /f "delims== tokens=1,2" %%G in (chapters.txt) do (
    	if [%%G]==[TAG:title] (
    		ren %%F "%%H.mkv"
    		goto :break
    	)
    )
    :break
    goto :eof
    Quote Quote  
  5. Mediainfo would pull it off too, download Mediainfo CLI, put a correct path for it in script and drop any amount of files on this batch script:
    Code:
    @echo off
    SETLOCAL
    set "mediainfo=C:\tools\Mediainfo CLI\Mediainfo.exe"
    set "temp_folder=C:\Temp"
    if not exist "%temp_folder%" MD "%temp_folder%"
    
    :start
    if "%~n1"=="" echo end&ENDLOCAL&echo press any key to exit&pause>nul&goto :eof
    "%mediainfo%" "%~1" > "%temp_folder%\mediainfo.txt"
    findstr /c:"Title    "  "%temp_folder%\mediainfo.txt" > "%temp_folder%\temp.txt"
    if %errorlevel%==0 call :rename "%~1" &shift&goto :start
    echo No title found in %~nx1
    shift
    goto :start
    
    :rename <filename>
    set /p title= < "%temp_folder%\temp.txt"
    set title=%title:*: =%
    rename "%~1" "%title%%~x1"
    echo %~nx1   renamed to ----^> %title%%~x1
    goto :eof
    Quote Quote  
  6. Very clever batch files _AI_ and JVRaines. I'm putting those in my engineering notebook.
    Quote Quote  
  7. Thanks for the help guys, MUCH appreciated. I happened to find Advanced Renamer as well, before I got the replies, and it is able to use ExifTool to do it perfect. (well, mostly perfect, I still ran into trouble with how MKVToolNix as was adding 2 chapters to each split file, but after some elbow grease I got it sorted out).

    @johnmeyer: lol, yep, 2 forums; after the d9 post getting almost no attention, and me needing this done, I posted here as well, where it seems the forum is a bit more active.

    Unfortunately, the person who created the Mr. Magoo files didn't keep them in any sort of chronological order, so what I have to so is watch it in AVS Video Remaker, use the original chapters as a guide (the person who added those didn't do a great job), delete them and add my own chapters with the name shown in the episode.

    THEN, since AVS software won't remake it with the chapters properly, and it also won't allow you to export the chapters to an xml list or anything, I have to save it as a project, open the project file as a text file, find all the chapter names and timestamps, convert the timestamps into the time format ToolNix uses in it's chapter editor, with some code I wrote to convert it, copy/paste all chapter names and converted timestamps, then split the file into each individual chapter.

    ridic amount of work to do what should be pretty basic simple stuff, done in a single app, lol.

    To add salt to the wound, I'm going to try reencoding them to HEVC afterward! LOL
    Quote Quote  



Similar Threads

Visit our sponsor! Try DVDFab and backup Blu-rays!