Well, I wrote a little script to auto-generate the nfo files by parsing the file names.
It asks you for a file- and file name pattern.
As an example you could enter "c:\music\*.mp4" as file pattern and "%artist% - %title%" as file name pattern.
Maybe someone else also has use for it.
You'll need
AutoHotkey to run the script. (just download+install AHK, put the code in a .ahk file and run it)
Code:
;Get folder and pattern from user
InputBox, Path, Enter a file path, Enter a the full path to a file or use the wildcart (*) to use multiple files. ,,,,,,,, %A_ScriptDir%\*.mp4
InputBox, rawPattern, Pattern to parse the filename..., Use any of those in your pattern:`n`%title`%`, `%artist`%`, `%album`%`, `%genre`%`, `%runtime`%`, `%plot`%`, `%year`%`, `%director`%`, `%studio`%`, `%track`%,,,,,,,, `%artist`% - `%title`%
;Quick parse to get the used tags
possibleTags := ["%title%","%artist%","%genre%","%runtime%","%plot%","%year%","%director%","%studio%","%track%"]
usedTags := []
Loop % possibleTags.MaxIndex() {
If (InStr(rawPattern,possibleTags[A_Index]))
usedTags.Insert(SubStr(possibleTags[A_Index],2,StrLen(possibleTags[A_Index])-2))
}
;Create actual RegEx pattern
pattern := "O)"
percentOpen := False
escapeChars := "\.*?+[{|()^$"
Loop, Parse, rawPattern
{
currentChar := A_LoopField
Loop, Parse, escapeChars
If (currentChar = A_LoopField)
currentChar := "\" A_LoopField
If (currentChar = "%") {
If (percentOpen)
currentChar := ">.+)"
Else
currentChar := "(?P<"
percentOpen := !percentOpen
}
pattern .= currentChar
}
pattern .= "\.mp4"
;Parse all filenames in the chosen directory
Loop, %Path%,, 1
{
;Run the the regex pattern on a file name
RegExMatch(A_LoopFileName, pattern, MediaInfo)
;Generate full path to the nfo file that's gonna be created
nfoFile := SubStr(A_LoopFileFullPath,1,StrLen(A_LoopFileFullPath)-3) "nfo"
FileDelete, % nfoFile ;Delete in case it already exists
;Generate nfo content using all the tags the user chose
nfoContent := "<musicvideo>`n"
Loop % usedTags.MaxIndex() {
tagName := usedTags[A_Index]
nfoContent .= " <" tagName ">" MediaInfo[tagName] "</" tagName ">`n"
}
nfoContent .= "</musicvideo>"
;Create the nfo file, append the content to it and hide the file
FileAppend, % nfoContent, % nfoFile
FileSetAttrib, ^H, % nfoFile
}