Jump to content

Movie Sorter


SkellySoul
 Share

Recommended Posts

Hello ;)

I made this script because I have many movies and they get self-extracted once they have finished downloading and they get put into a folder and the rar , movie and subtitles files all get mixed into one folder.

This can be very hard to figure what I need and don't need.

So this script finds some of the common movie types and subtitles and moves them all into a different folder and save that mess in the other folder for later.

Global $FileTypes[4]

$FileTypes[0] = "Srt"
$FileTypes[1] = "Avi"
$FileTypes[2] = "Mp4"
$FileTypes[3] = "Mkv"

$Search = FileFindFirstFile("*.*")

If $Search = -1 Then
    MsgBox(0, "Error", "No files/directories matched the search pattern")
    Exit
EndIf

While 1
    $File = FileFindNextFile($Search)
    If @Error Then
        ExitLoop
    Else
        $i = 0
        Do
            If StringTrimLeft($File , StringLen($File) -3) = $FileTypes[$i] Then
                FileMove(@ScriptDir & "\" & $File , @ScriptDir & "\Other\" & $File)
            EndIf
            $i +=1
        Until $i = 4 Or @Error
    EndIf
WEnd

FileClose($Search)

Yes, This is hard to explain. (people who use "Jdownloader" probably know what I am talking about)

Edited by SkellySoul
Link to comment
Share on other sites

I try to simplify...

Global $FileTypes[5]=[4,'Srt','Avi','Mp4','Mkv']
$Search = FileFindFirstFile ( "*.*" )
If $Search = -1 Then Exit MsgBox ( 0, "Error", "No files/directories matched the search pattern" )

While 1
    $File = FileFindNextFile ( $Search )
    If Not @Error Then
        $_Ext = _GetExt ( $File )
        For $_I = 1 To UBound ( $FileTypes ) -1
            If $FileTypes[$_I] = String ( $_Ext ) Then _
            FileMove ( @ScriptDir & "\" & $File , @ScriptDir & '\Other\' & $File, 9 )
        Next
    Else    
        FileClose ( $Search )
        ExitLoop 
    EndIf
WEnd

Func _GetExt ( $_FileName )
    $_FileName = StringSplit ( $_FileName, '.' )
    If Not @error Then      
        Return $_FileName[$_FileName[0]]
    Else
        Return 0
    EndIf       
EndFunc ;==> _GetExt ( )
Edited by wakillon

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...