Sign in to follow this  
Followers 0
torels

Array Question (a bit complicated)

5 posts in this topic

I always get an error with the program in the _toFile function...

this is the problem: if I have let's say 6 folders in my iPod (stored in $folder array) Tue program copies only 5 and gives a super-script error

any ideas ?

#NoTrayIcon
;iPod trensfer - torels_
#include <array.au3>
#include <GUIConstants.au3>

Dim $file
Dim $folder[1]
Dim $files[1]
Dim $return[5]
Global $path
Global $doing
Global $name, $artist, $album, $destpath, $e, $string
$i = 0

FileInstall(".\iPod_transfer.jpg", @TempDir & "\iPod_transfer.jpg")

#region ### TRAY MENU START ###
Opt("TrayMenuMode",1)
$stop = TrayCreateItem("&Stop Transfering!")
TrayCreateItem("")
$exit = TrayCreateItem("&Exit")
TraySetState()

#Region ### START Koda GUI section ### Form=
$Form11 = GUICreate("iPod transfer - torels_", 626, 390)
GUISetCursor (2)
GUISetBkColor(0xFFFFFF)
$Pic1 = GUICtrlCreatePic(@TempDir & "\iPod_transfer.jpg", 8, 8, 609, 137)
$bPath = GUICtrlCreateButton("...", 584, 224, 33, 20)
$iPath = GUICtrlCreateInput("", 56, 224, 521, 21)
$Label1 = GUICtrlCreateLabel("Save to:", 8, 227, 44, 17)
$Devices = GUICtrlCreateCombo("Devices", 224, 192, 169, 25)
$Label2 = GUICtrlCreateLabel("iPod Device:", 272, 168, 65, 17)
$OK = GUICtrlCreateButton("OK", 192, 264, 241, 33)
$Progress = GUICtrlCreateProgress(8, 328, 609, 25)
$lFolder = GUICtrlCreateLabel("", 10, 360,500)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

TraySetToolTip("iPod Transfer - torels_")
TraySetIcon("Shell32.dll",-115)
#endregion ### TRAY ###

$drives = DriveGetDrive("removable")

For $i = 1 To $drives[0]
    GUICtrlSetData($Devices, StringUpper($drives[$i]) & "\")
Next

While 1
    Switch GUIGetMsg()
        Case - 3
            Exit
        Case $bPath
            Global $destpath = FileSelectFolder("Select the destination folder", Default)
            GUICtrlSetData($iPath, $destpath)
        Case $OK
            if FileExists(GUICtrlRead($iPath)) then
                _Is_iPod(GUICtrlRead($Devices))
            Else
                MsgBox(16, "Error!", GUICtrlRead($iPath) & " Is not a valid Path!!")
            EndIf
    EndSwitch
        
    if TrayGetMsg() = $exit then exit
WEnd
 
;================================================ GET FILES AND ELABORATE EVERYTHING ========================================>

Func _Is_iPod($path)
    If DriveGetType($path) = "removable" And FileExists($path & "\iPod_Control\iTunes\") Then
        $path &= "iPod_Control\Music\"
        _Get_Folders($path)
    Else
        MsgBox(0,"Error!",GUICtrlRead($Devices) & " Is not a valid Drive!!")
    EndIf
EndFunc   ;==>_Is_iPod

Func _Get_Folders($criteria = $path)
    $f = FileFindFirstFile($criteria & "*.*")
    While 1
        $felement = FileFindNextFile($f)
        If @error Then ExitLoop
        _ArrayAdd($folder, $criteria & $felement & "\*.*")
    WEnd
    _Get_Files()
EndFunc   ;==>_Get_Folders

Func _Get_Files()
    For $i = 1 To (UBound($folder) - 1)
        $f = FileFindFirstFile($folder[$i])
        While 1
            $file &= FileFindNextFile($f) & " "
            If @error Then ExitLoop
        WEnd
        _ArrayAdd($files, $file)
        $file = ""
    Next

    _ToFile(1)
EndFunc   ;==>_Get_Files

Func _ToFile($i)
    If $i < UBound($files) Then
        $size = DirGetSize(GUICtrlRead($Devices) & "iPod_Control\Music\")
        $string = StringSplit($files[$i], " ")
        For $e = 1 To (UBound($string) - 1)
            if TrayGetMsg() = $stop then 
                $i = Ubound($files) - 1
                GUISetState(@SW_SHOW)
            EndIf
            $doing += FileGetSize(StringLeft($folder[$i], StringLen($folder[$i]) - 3) & $string[$e])
            Songinfo(StringTrimRight($folder[$i], 3) & $string[$e])
            FileCopy(StringLeft($folder[$i], StringLen($folder[$i]) - 3) & $string[$e], $destpath & "\" & $return[1] & " - " & $return[2] & " - " & $return[3] & "." & StringRight($files[$e], 5))
            GUICtrlSetData($Progress,(($e * 10) / (UBound($string) - 1)) * 10)
            GUICtrlSetData($lFolder,"Folder " & $i & " - " & $return[1] & " - " & $return[2] & " - " & $return[3] & "." & StringRight($files[$e], 5))
        Next
    
        $i += 1
        _ToFile($i)
    EndIf
    GUICtrlSetData($Progress,0)
EndFunc   ;==>_ToFile


Func Songinfo($playdir2) ;Finds Title|Author|Album for any media file
    Dim $return[5]
    $return[1] = _GetExtProperty($playdir2, 10);name
    $return[2] = _GetExtProperty($playdir2, 16);atrist
    $return[4] = _GetExtProperty($playdir2, 21);duration
    $return[3] = _GetExtProperty($playdir2, 17);album
    
    if $return[1] = "" then $return[1] = $string[$e]
EndFunc   ;==>Songinfo


Func _GetExtProperty($sPath, $iProp)
    Local $iExist, $sFile, $sDir, $oShellApp, $oDir, $oFile, $aProperty, $sProperty
    $iExist = FileExists($sPath)
    If $iExist = 0 Then
        SetError(1)
        Return 0
    Else
        $sFile = StringTrimLeft($sPath, StringInStr($sPath, "\", 0, -1))
        $sDir = StringTrimRight($sPath, (StringLen($sPath) - StringInStr($sPath, "\", 0, -1)))
        $oShellApp = ObjCreate("shell.application")
        $oDir = $oShellApp.NameSpace($sDir)
        $oFile = $oDir.Parsename($sFile)
        If $iProp = -1 Then
            Local $aProperty[35]
            For $i = 0 To 34
                $aProperty[$i] = $oDir.GetDetailsOf($oFile, $i)
            Next
            Return $aProperty
        Else
            $sProperty = $oDir.GetDetailsOf($oFile, $iProp)
            If $sProperty = "" Then
                Return "Unknown"
            Else
                Return $sProperty
            EndIf
        EndIf
    EndIf
EndFunc   ;==>_GetExtProperty

thanks in advance


Some Projects:[list][*]ZIP UDF using no external files[*]iPod Music Transfer [*]iTunes UDF - fully integrate iTunes with au3[*]iTunes info (taskbar player hover)[*]Instant Run - run scripts without saving them before :)[*]Get Tube - YouTube Downloader[*]Lyric Finder 2 - Find Lyrics to any of your song[*]DeskBox - A Desktop Extension Tool[/list]indifference will ruin the world, but in the end... WHO CARES :P---------------http://torels.altervista.org

Share this post


Link to post
Share on other sites



... Anybody?

:)


Some Projects:[list][*]ZIP UDF using no external files[*]iPod Music Transfer [*]iTunes UDF - fully integrate iTunes with au3[*]iTunes info (taskbar player hover)[*]Instant Run - run scripts without saving them before :)[*]Get Tube - YouTube Downloader[*]Lyric Finder 2 - Find Lyrics to any of your song[*]DeskBox - A Desktop Extension Tool[/list]indifference will ruin the world, but in the end... WHO CARES :P---------------http://torels.altervista.org

Share this post


Link to post
Share on other sites

Share this post


Link to post
Share on other sites

Actualy, UBound will return the number of subscripts, not the maximum index you can use.

The StringSplit function sets the 0th item to be the maxium index you can use.

Try changing this:

For $e = 1 To (UBound($string) - 1)oÝ÷ Ùú+¶¬jëh×6For $e = 1 To $string[0]

[quote name='Valik' post='301213' date='Jan 31 2007, 10:36 PM']You seem to have a habit of putting things in the wrong place. I feel sorry for any female you attempt to have sex with.[/quote][font="Lucida Sans Unicode"][/font]

Share this post


Link to post
Share on other sites

thanks CoePSX and Jrowe!!

:)

I didn't test it because I have about 10 GB of music con my iPod so I'd take a lot of time to copy it all to the computer, but anyway it should work :)


Some Projects:[list][*]ZIP UDF using no external files[*]iPod Music Transfer [*]iTunes UDF - fully integrate iTunes with au3[*]iTunes info (taskbar player hover)[*]Instant Run - run scripts without saving them before :)[*]Get Tube - YouTube Downloader[*]Lyric Finder 2 - Find Lyrics to any of your song[*]DeskBox - A Desktop Extension Tool[/list]indifference will ruin the world, but in the end... WHO CARES :P---------------http://torels.altervista.org

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