I made some script to scrape all the files of a season and all movies in their own folders for easy addition to Plex using the XMBC Agent.
The only metadata you get is what you have in the filename or the folder name.
Simply copy paste the files into a txt file you will rename as .vbs
For Episodes:
I like to name my daily show this way: YYxMMDD (Year x Month Day), then Name of the Show and “-” and Actors and “-” and Title of the episode. Which gives:
14x0809 PlexSeries - Ismelda, Plex, XBMC - Nice VbScript
This script will convert the YYxMMDD in a proper aired date, add the series name to the director tag and each actors (must be separated by comas and no more than 4) to the credits. The title of the episode in Plex will be the “Actors - Episode Name”.
The script will work also for files named
"01x001 Series - EpisodeTitle" not adding any aired date and only adding the Series to the Director tag. and the “EpisodeTitle” as title
or
"01x02 EpisodeTitle" only adding the “EpisodeTitle” as title without the numbering.
The script has to be put where the files are. It will not overwrite any pre-existing .nfo file create with the name of the episodes.
[spoiler]
’============================================================================================================[/spoiler]
'Create a .nfo file from the title of the video file used with this format :
’ “YYxMMDD Series Title - Credits1, Credits2, Credits3, Credits 4 - Title of the episode”
'-“YY” is either the season number or the year if from 2009 (can be change if you set the value to sYear) and up
'-“MM” is the month and
'-“DD” the day.
’ If the numbering is less than 7 characters then it is ignored
'-“Series Title” goes into the Director tag
'-“Credits1 to 4” is optional and will fill the credits if it exists and is used for the actors up to 4
’ and each must be separated with a comma
'-“Title of the episode” is just the name of the episode.
'============================================================================================================set wshell = createobject(“WScript.Shell”)
CurPath = WShell.Currentdirectory
Set fso = CreateObject(“Scripting.FileSystemObject”)
Set objFolder = fso.GetFolder(curpath)
Set files = objFolder.Files
dim filename, dF, tF, sF, cF1, cF2, cF2t, cF3, cFt3, cF4, cF4t, i0, i1, i2, i3, i4, i5, i6, i7, i, nF, filesys, sYear
Set filesys = CreateObject(“Scripting.FileSystemObject”)
sYear = “09”
For each fileIdx In files
If (fso.GetExtensionName(fileIdx.Path) <> “jpg” AND fso.GetExtensionName(fileIdx.Path) <> “vbs” AND fso.GetExtensionName(fileIdx.Path) <> “ini”) then
i0=0
i1=0
i2=0
i3=0
i4=0
i5=0
i6=0
dF=""
tF=""
sF=""
cF1=""
cF2=""
cF2t=""
cF3=""
cFt3=""
cF4=""
cF4t=""
filename = fso.GetBaseName(fileIdx)nF = InStr(filename,".cd")-1 If nF >0 Then filename = Mid(filename,1,nF) & ".cd1" End If if not filesys.FileExists(CurPath & "\" & filename & ".nfo") Then 'Create the xml file Set xmlDoc = CreateObject("Microsoft.XMLDOM") Set objRoot = xmlDoc.createElement("episodedetails") xmlDoc.appendChild objRoot 'Tilte of the episode with the credited actors Set objName = xmlDoc.createElement("title") i8 = InStr(filename," ")+1 i0 = InStr(filename," - ") +3 'Look for the starting position of the episode name after the " - " i7 = InStr(filename,".cd") 'If there is a .cdX part, check the position of the ".cd" if i7 >0 then 'If there is a ".cd" i = i7-i0 'The title length is from the start of the title (i0) to the position of the ".cd" If i0>1 Then 'if there is a " - " tF = Mid(filename,i0,i) 'extract the string from the start to the end of the title length Else tF = Mid(filename,1,i7) 'if there is no " - " then the title starts at the 1st character End If Else 'if there is no ".cd" If i0>3 Then 'if there is a " - " tF = Mid(filename,i0,200) 'extract the string from the start to the end of the title length Else 'If there is no " - " If i8>1 Then 'If there is a space tF = Mid(filename, i8,200) 'Get the title from after the 1st space Else tF = filename 'then the whole title is the filename End If End If End If objName.Text = tF objRoot.appendChild objName Set objName = xmlDoc.createElement("plot") objName.Text = "" objRoot.appendChild objName 'If the date of release is valid Set objName = xmlDoc.createElement("aired") i1 = InStr(filename," ") If i1=8 Then 'For year from 2009 if Left(filename,2)>sYear Then d="20" & Left(filename,2) & "-" & Mid(filename,4,2) & "-" & Mid(filename,6,2) End If End If objName.Text = d objRoot.appendChild objName 'Add the series name Set objName = xmlDoc.createElement("director") i0 = InStr(filename,"-")-1 i1 = InStr(filename," ")+1 i2 = i0-i1 if i2 > 0 Then sF = Mid(filename,i1, i2) Else sF = "" End If objName.Text = sF objRoot.appendChild objName 'First credit if it exists Set objName = xmlDoc.createElement("credits") i3 = InStr(tF,",")-1 If i3>0 Then cF1 = Mid(tF,1,i3) Else i4 = InStr(tF,"-")-2 If i4>0 Then cF1 = Mid(tF,1,i4) Else cF1 = "" End If End if objName.Text = cF1 objRoot.appendChild objName 'If there is a second credit If i3 > 0 Then Set objName = xmlDoc.createElement("credits") cF2t = Mid (tF, (i3+3),100) 'Wscript.Echo cF2t i5 = InStr(cF2t,",")-1 If i5>0 Then cF2 = Mid(cF2t,1,i5) Else i4=InStr(cF2t,"-")-2 If i4>0 Then cF2 = Mid(cF2t,1,i4) End If End If objName.Text = cF2 objRoot.appendChild objName End If 'If there is a third credit If i5>0 Then Set objName = xmlDoc.createElement("credits") cF3t = Mid(cF2t,(i5+3),100) 'Wscript.Echo cF3t i6 = InStr(cF3t,",")-1 If i6>0 Then cF3 = Mid(cF3t,1,i6) Else i4=InStr(cF3t,"-")-2 If i4>0 Then cF3 = Mid(cF3t,1,i4) End If End If objName.Text = cF3 objRoot.appendChild objName End If 'If there is a 4th credit if i6>0 Then Set objName = xmlDoc.createElement("credits") cF4t = Mid(cF3t,(i6+3),100) 'Wscript.Echo cF4t i4=InStr(cF4t,"-")-2 cF4 = Mid(cF4t,1,i4) objName.Text = cF4 objRoot.appendChild objName End If 'if not filesys.FileExists(CurPath & "\" & filename & ".nfo") Then set rdr = CreateObject ( "MSXML2.SAXXMLReader") set wrt = CreateObject ( "MSXML2.MXXMLWriter") Set oStream = CreateObject ( "ADODB.STREAM") oStream.Open oStream.Charset = "utf-8" wrt.indent = True wrt.encoding = "utf-8" wrt.output = oStream Set rdr.contentHandler = WRT Set rdr.errorHandler = WRT rdr.Parse xmlDoc wrt.flush oStream.SaveToFile CurPath & "\" & filename & ".nfo", 2 Set rdr = Nothing Set WRT = Nothing End If End If
Next
Wscript.Echo “Done”
For Movies:
The script will take the name of the folder as title and if there is a year into paranthesis will also add the year to the xml.
You can edit the script to add your own values to the Studio (nStudio), the Collections (nSet) and the Country (nCountry)
The script will parse the first level of subfolder in which it is adding a movie.nfo in each folder. If you have say a year folder and put the script there, it will scan all the folders there and add a movie.nfo file (if none is already there).
[spoiler]
set wshell = createobject(“WScript.Shell”)[/spoiler]
CurPath = WShell.Currentdirectory
Set fso = CreateObject(“Scripting.FileSystemObject”)
Set objFolder = fso.GetFolder(curpath)
Set files = objFolder.Files
Set filesys = CreateObject(“Scripting.FileSystemObject”)
Dim nStudio, nConuntry, nSet, nYear, i, j, n, nMovie
nStudio = " "
nSet = " "
nConuntry = " "Sub ShowFolderList(folderspec)
Dim fs, f, f1, fc, s
Set fs = CreateObject(“Scripting.FileSystemObject”)
Set f = fs.GetFolder(folderspec)
Set fc = f.SubFoldersFor Each f1 in fc
If not filesys.FileExists(CurPath & “” & f1.name & “” & “movie.nfo”) Then
i = InStr(f1.name,"(")+1
j = InStr(f1.name,")")-i
If i>1 Then
n = i-3
nMovie = Mid(f1.name,1,n)
nYear = Mid(f1.name,i,j)
Else
nMovie = f1.name
nYear = “”
End If
Set files = objFolder.Files
Set filesys = CreateObject(“Scripting.FileSystemObject”)
Set xmlDoc = CreateObject(“Microsoft.XMLDOM”)
Set objRoot = xmlDoc.createElement(“movie”)
xmlDoc.appendChild objRoot
Set objName = xmlDoc.createElement(“id”)
objName.Text = " "
objRoot.appendChild objName
Set objName = xmlDoc.createElement(“title”)
objName.Text = nMovie
objRoot.appendChild objName
Set objName = xmlDoc.createElement(“originaltitle”)
objName.Text = " "
objRoot.appendChild objName
Set objName = xmlDoc.createElement(“releasedate”)
objName.Text = " "
objRoot.appendChild objName
Set objName = xmlDoc.createElement(“year”)
objName.Text = nYear
objRoot.appendChild objName
Set objName = xmlDoc.createElement(“tagline”)
objName.Text = " "
objRoot.appendChild objName
Set objName = xmlDoc.createElement(“outline”)
objName.Text = " "
objRoot.appendChild objName
Set objName = xmlDoc.createElement(“plot”)
objName.Text = " "
objRoot.appendChild objName
Set objName = xmlDoc.createElement(“studio”)
objName.Text = nStudio
objRoot.appendChild objName
Set objName = xmlDoc.createElement(“mpaa”)
objName.Text = " "
objRoot.appendChild objName
Set objName = xmlDoc.createElement(“rating”)
objName.Text = " "
objRoot.appendChild objName
Set objName = xmlDoc.createElement(“certification”)
objName.Text = " "
objRoot.appendChild objName
Set objName = xmlDoc.createElement(“genre”)
objName.Text = " "
objRoot.appendChild objName
Set objName = xmlDoc.createElement(“director”)
objName.Text = " "
objRoot.appendChild objName
Set objName = xmlDoc.createElement(“country”)
objName.Text = nConuntry
objRoot.appendChild objName
Set objName = xmlDoc.createElement(“set”)
objName.Text = nSet
objRoot.appendChild objName
Set objName = xmlDoc.createElement(“credits”)
objName.Text = " "
objRoot.appendChild objName
Set objName = xmlDoc.createElement(“runtime”)
objName.Text = " "
objRoot.appendChild objName
Set objAct = xmlDoc.createElement(“actor”)
objRoot.appendChild objAct
Set objName = xmlDoc.createElement(“name”)
objName.Text = " "
objAct.appendChild objName
Set objName = xmlDoc.createElement(“role”)
objName.Text = " "
objAct.appendChild objName
Set objAct = xmlDoc.createElement(“actor”)
objRoot.appendChild objAct
Set objName = xmlDoc.createElement(“name”)
objName.Text = " "
objAct.appendChild objName
Set objName = xmlDoc.createElement(“role”)
objName.Text = " "
objAct.appendChild objName
Set objAct = xmlDoc.createElement(“actor”)
objRoot.appendChild objAct
Set objName = xmlDoc.createElement(“name”)
objName.Text = " "
objAct.appendChild objName
Set objName = xmlDoc.createElement(“role”)
objName.Text = " "
objAct.appendChild objName
Set objAct = xmlDoc.createElement(“actor”)
objRoot.appendChild objAct
Set objName = xmlDoc.createElement(“name”)
objName.Text = " "
objAct.appendChild objName
Set objName = xmlDoc.createElement(“role”)
objName.Text = " "
objAct.appendChild objName
Set objAct = xmlDoc.createElement(“actor”)
objRoot.appendChild objAct
Set objName = xmlDoc.createElement(“name”)
objName.Text = " "
objAct.appendChild objName
Set objName = xmlDoc.createElement(“role”)
objName.Text = " "
objAct.appendChild objName
Set objAct = xmlDoc.createElement(“actor”)
objRoot.appendChild objAct
Set objName = xmlDoc.createElement(“name”)
objName.Text = " "
objAct.appendChild objName
Set objName = xmlDoc.createElement(“role”)
objName.Text = " "
objAct.appendChild objName
Set objAct = xmlDoc.createElement(“actor”)
objRoot.appendChild objAct
Set objName = xmlDoc.createElement(“name”)
objName.Text = " "
objAct.appendChild objName
Set objName = xmlDoc.createElement(“role”)
objName.Text = " "
objAct.appendChild objName
Set objAct = xmlDoc.createElement(“actor”)
objRoot.appendChild objAct
Set objName = xmlDoc.createElement(“name”)
objName.Text = " "
objAct.appendChild objName
Set objName = xmlDoc.createElement(“role”)
objName.Text = " "
objAct.appendChild objName
set rdr = CreateObject ( “MSXML2.SAXXMLReader”)
set wrt = CreateObject ( “MSXML2.MXXMLWriter”)
Set oStream = CreateObject ( “ADODB.STREAM”)
oStream.Open
oStream.Charset = “utf-8”wrt.indent = True
wrt.encoding = “utf-8”
wrt.output = oStream
Set rdr.contentHandler = WRT
Set rdr.errorHandler = WRT
rdr.Parse xmlDoc
wrt.flush
'oStream.SaveToFile CurPath & “” & f1.name & “” & f1.name & “.nfo”, 2
oStream.SaveToFile CurPath & “” & f1.name & “” & “movie.nfo”, 2Set rdr = Nothing
Set WRT = Nothing
End If
Next
End SubShowFolderList CurPath
Wscript.Echo “Done”
If you need help on configuring the script to fit your files naming, please feel free to ask.