option explicit ' XBMCRenamer ' ' ' This is a script for Directory Opus. ' See http://www.gpsoft.com.au/DScripts/redirect.asp?page=scripts for development information. ' ' ' ' Called by Directory Opus to initialize the script Function OnInit(initData) initData.name = "XBMC ReNamer" initData.desc = "" initData.copyright = "" initData.version = "1.0" initData.default_enable = True Dim cmd Set cmd = initData.AddCommand cmd.name = "XBMCReNamer" cmd.method = "OnRename" cmd.desc = "Renames TV Episodes To XBMC Standard" cmd.label = "XBMCReNamer" cmd.template = "" End Function ' Implement the OnRename command Function OnRename(Data) dim objCmd : Set objCmd = DOpus.NewCommand Dim mystring : Set mystring = data.func.sourcetab.path Dim myNumber Dim myLength myLength = Len(mystring) Dim i For i = 1 To myLength If Asc(Mid(mystring, i, 1)) <> 32 Then If Asc(Mid(mystring, i, 1)) >= 48 And Asc(Mid(mystring, i, 1)) <= 57 Then myNumber = myNumber & Mid(mystring, i, 1) if myNumber < 10 then myNumber = "0" & myNumber End If End If Next objCmd.RunCommand("@set var=" & myNumber & "") objCmd.RunCommand("Rename FILEINFO NUMBER 01 BY 1 TO {parent2}.S{$var}E[#].{ext}") Set objCmd = Nothing End Function