Sign in to follow this  
Followers 0
yousifucv

TV Show Renamer

3 posts in this topic

I wouldn't say I'm new to AutoIt, but I stay very simple when using it (mostly because I don't know how to use stuff other than basic operations).

I made this renamer to clean up tv shows' names.

http://www.youtube.com/watch?v=Gcf7eHitaJs

http://rapidshare.com/files/170919076/Tv_show_renamer.zip

The .au3 and .exe are inside the .zip, along with the readme.txt

Please watch the video and read the 'READ ME.txt' to avoid annoyances, :)

You can think of this as a beta I guess. I will get back to changing a few things after exams.

If you have any comments, suggestions, or advice, please post them.

Enjoy.

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

I am using something similar, that IMHO uses little bit better coding techniques.

It uses episode lists copied from wikipedia so the list has slightly different format than yours.

Program is very intuitive so I think everybody should be able to know what to do with it.

What you need is just to copy a list of episodes from wikipedia to a text file. It should look something like this:

81  501 "Search and Rescue #2"  Andy Mikita Martin Gero July 11, 2008 (Sci Fi Channel)
Carter launches a res...
82  502 "The Seed"  William Waring  Joseph Mallozzi & Paul Mullie   July 18, 2008 (Sci Fi Channel)
The clo...
83  503 "Broken Ties"   Ken Girotti Joseph Mallozzi & Paul Mullie   July 25, 2008 (Sci Fi Channel)
Ron...
84  504 "The Daedalus Variations"   Andy Mikita Alan McCullough August 1, 2008 (Sci Fi Channel)
The Daed...

#cs ----------------------------------------------------------------------------

 AutoIt Version: 3.2.12.1
 Author:         Markos

 Script Function:
    Rename episodes from a file list

#ce ----------------------------------------------------------------------------

#Include <File.au3>
#include <Misc.au3>
;~ #include <Array.au3>

Global $sDir = FileSelectFolder('Select folder containg the show', '', 6, @ScriptDir)
    If @error Then Exit
FileChangeDir($sDir)
Global $SourceFile = FileSaveDialog('Select file containing episode names', $sDir, 'Text files (*.txt)|All (*.*)', 2, 'names.txt')
    If @error Then Exit
Global $sShowName = InputBox(@ScriptName,   'Type in the show name with formatting'  & @CRLF & @CRLF & _
                                            'ex: "Stargate Atlantis - 5x%1 - %2.avi" will result in episode names: ' & _
                                            '"Stargate Atlantis - 5x01 - Search and Rescue #2.avi"' & @CRLF & _
                                            '%1 substitutes episode number' & @CRLF & _
                                            '%2 substitutes episode name', 'SERIES_NAME - SEASONx%1 - %2.avi', '', 650, -1)
    If @error Then Exit
    If $sShowName = '' Then Exit MsgBox(48, @ScriptName, 'No formatting specified!')
Global $iFirstEpisode = InputBox(@ScriptName, "Type in the first episode number in the folder"  & @CRLF & @CRLF & _
                                    'Ex: If the first file in the folder is "SGA 5x03.avi" then type in 3' & @CRLF & _
                                    'Note: The episode list file would have to start from episode number 3!', 1, '', 400, -1)
    If @error Then Exit
    If $iFirstEpisode = '' Then $iFirstEpisode = 1
Global $hSourceFile = FileOpen($SourceFile, 0)
    If @error Then Exit MsgBox(0, @ScriptName, 'Unable to open file ' & $SourceFile)
Global $aFileList = _FileListToArray($sDir, '*.avi', 1)
    If @error = 1 Then Exit MsgBox(0, @ScriptName, 'Path not found or invalid')
    If @error = 4 Then Exit MsgBox(0, @ScriptName, 'No file(s) found')

;~ _ArrayDisplay($aFileList)

Global $sSourceFile
Local $Even = True
Local $sLine = FileReadLine($hSourceFile)
While @error <> -1
    If $Even Then $sSourceFile &= $sLine
    $Even = Not $Even
    $sLine = FileReadLine($hSourceFile)
WEnd

Global $aEpisodeList = StringRegExp($sSourceFile, '\"(.*?)\"', 3)

;~ _ArrayDisplay($aEpisodeList)

Local $sDestinationFile
Local $1 = StringInStr($sShowName, '%1')
Local $2 = StringInStr($sShowName, '%2')

For $i = 1 To UBound($aFileList) - 1
    $sDestinationFile = StringLeft($sShowName, _Iif($1<$2, $1, $2) - 1) & _
                            _Iif($1<$2, StringFormat('%02d', $iFirstEpisode+$i-1), $aEpisodeList[$i-1]) & _
                            StringMid($sShowName, _Iif($1<$2, $1, $2)+2, _Iif($1<$2, $2-$1, $1-$2)-2) & _
                            _Iif($2<$1, StringFormat('%02d', $iFirstEpisode+$i-1), $aEpisodeList[$i-1]) & _
                            StringMid($sShowName, _Iif($1<$2, $2, $1)+2)
;~  MsgBox(0, '', 'from:' & @CRLF & $aFileList[$i] & @CRLF & 'to:' & @CRLF & $sDestinationFile)
    FileMove($aFileList[$i], $sDestinationFile)
    FileMove(StringTrimRight($aFileList[$i], 3) & 'srt', StringTrimRight($sDestinationFile, 3) & 'srt')
Next

MsgBox(64, @ScriptName, 'Finished!')

Func OnAutoItExit()
    If IsDeclared('hSourceFile') Then FileClose($hSourceFile)
EndFunc
Edited by Markos

Share this post


Link to post
Share on other sites

Heh. The truth is I'm still not that good enough to see how it works, but it does. Cool.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0