Sign in to follow this  
Followers 0
smstroble

Advanced File Info

4 posts in this topic

#1 ·  Posted (edited)

Ok, so hears the deal. I would like to make a program to replace sharepod, transfers music from ipod to pc, for my ipod. I want it to rename and reorganize the music according to track title, album name, and artist. However i cannot figure out how to pull info from the file summary...

Is there a command i overlooked or a DLL call that i can use? Something like FileGetInfo($filename, $entry)?

NeverMind. i found this

;===============================================================================
;
; Description:            Returns the requested property or an array of all properties
;                            for the specified file.
; Syntax:                _GetFileProperty( $sPath, optional $sProp )
; Parameter(s):        $sPath -    Path and filename of the file to query
;                            $sProp -    (optional) Name of property to return
;                                        if not specified will return array of all properties
; Requirement(s):        AutoIt 3.2 or higher
; Return Value(s):    On Success - Returns string value of property OR
;                                             Returns 2 dimensional array (property name,value)
;                            On Failure - Returns nothing
;                                             @error = 1 - file does not exist
;                                             @error = 2 - unable to get property
; Author(s):            Sean Hart (autoit AT hartmail DOT ca)
;                            (idea from GetExtProperty by Simucal, thanks)
; Note(s):                Special 
;
;===============================================================================
Func _GetFileProperty($sPath, $sProp = "")
    ; Declare local variables
    Local $sFile, $sDir, $oShell, $oDir, $oFile, $i, $count, $aProps[1][3]
    
    ; Init counter used for array of properties
    $count = 0
    
    ; Check file exists first
    If Not FileExists($sPath) Then
        SetError(1)
        Return
    Else
        ; Pull file name and directory from full file path
        $sFile = StringTrimLeft($sPath, StringInStr($sPath, "\", 0, -1))
        $sDir = StringTrimRight($sPath, (StringLen($sPath) - StringInStr($sPath, "\", 0, -1)))
        
        ; Create required objects
        $oShell = ObjCreate("shell.application")
        $oDir = $oShell.NameSpace($sDir)
        $oFile = $oDir.Parsename($sFile)
        
        ; Loop through 99 possible property numbers (allows for future additions to property fields)
        For $i = 0 to 99
            ; If no property specified then add to array
            If ($sProp = "") Then
                ; Only add if property name is not blank
                If ($oDir.GetDetailsOf($oDir.Items, $i) <> "") Then
                    ; Increase counter and redimension array
                    $count = $count + 1
                    ReDim $aProps[$count + 1][3]
                    
                    ; Add property name and value to array
                    $aProps[$count][1] = $oDir.GetDetailsOf($oDir.Items, $i)
                    $aProps[$count][2] = $oDir.GetDetailsOf($oFile, $i)
                EndIf
                
            ; If property name matches property being requested, return value
            ElseIf $oDir.GetDetailsOf($oDir.Items, $i) = $sProp Then
                Return $oDir.GetDetailsOf($oFile, $i)
            EndIf
        Next
        
        ; If array was populated return array, otherwise return error 2
        If $count > 0 Then
            Return $aProps
        Else
            SetError(2)
            Return
        EndIf
    EndIf
EndFunc   ;==>_GetFileProperty

this should be in the File.au3 standard UDF, could be very useful.

Edited by smstroble

MUHAHAHAHAHA

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Ok, so hears the deal. I would like to make a program to replace sharepod, transfers music from ipod to pc, for my ipod. I want it to rename and reorganize the music according to track title, album name, and artist. However i cannot figure out how to pull info from the file summary...

Is there a command i overlooked or a DLL call that i can use? Something like FileGetInfo($filename, $entry)?

There you go, nice... that actually will help me too, email me with ur code if u finish it, definately useful. Ignore the foillowing junk lol... I simply wont delete it for the waste of time i put into it lol

Well I see no one else has posted... so I decide I would try to help... I do not know about a command or dll to call, bu I did look on google for reding info from streams... incase you do not know what a stream is, it is a portion of a file, (extra info, such as a file summary)... ADS(Alternate Data Streams) allows for info or files to be placed inside of an existing file...the summary info you are desiring is a data stream, as far as accessing them, I have a function used in C++ for reading this summary stream: StgOpenStorage... the command used in C++ to get the info is IPropertySetStorage... you might try seeing if anyone can tell you the equivelent function and command in AutoIt v3(If you decide this the developers chat may be a good place to check) well I hope I helped a little

-Psibernetic, Psibernetic Computing (Omega Division)

Edited by Psibernetic

[sup]Psibernetic[/sup]My Creations:X-HideSecuracy

Share this post


Link to post
Share on other sites

Haha. I completed my code.

Only known problem is if there is no info it will make it .mp3 and possibly (not confirmed) fail to copy the whole file.

Note:Only copys .mp3's .m4b are itunes specific and will only work on the originating computer so copying them is usually a waste.

$search = FileFindFirstFile("J:\ipod_control\Music\F00\*.Mp3")
$orig = "J:\ipod_control\Music\F00\"
$F = "00"
While 1
    While 1
        $file = FileFindNextFile($search)
        If @error Then
            ExitLoop
        Else
            ;MsgBox(0, "", _GetFileProperty($orig & $file, "Title") & " | " & Stringstripcolon(_GetFileProperty($orig & $file, "Title")))
            FileCopy($orig & $file, "D:\ipod\" & _GetFileProperty($orig & $file, "Artist") & "\" & Stringstripcolon(_GetFileProperty($orig & $file, "Album Title")) & "\" & Stringstripcolon(_GetFileProperty($orig & $file, "Title")) & ".Mp3", 8)
            ;If NOT $chk Then
            ;    MsgBox(0, "error", "D:\ipod\" & _GetFileProperty($orig & $file, "Artist") & "\" & Stringstripcolon(_GetFileProperty($orig & $file, "Album Title")) & "\" & Stringstripcolon(_GetFileProperty($orig & $file, "Title")) & ".Mp3")
            ;EndIf
        EndIf
    WEnd
    FileClose($search)
    $F = StringRight("00" & ($F + 1), 2)
    If $F >= 49 Then
        MsgBox(0, "Done", "DONE!")
        Exit
    EndIf
    $orig = "J:\ipod_control\Music\F" & $F & "\"
    $search = FileFindFirstFile("J:\ipod_control\Music\F" & $F & "\*.Mp3")
WEnd


Func Stringstripcolon($string)
    $string = StringReplace($string, ":", "")
    $string = StringStripWS($string, 7)
    Return $string
EndFunc


;==============================================================================
;
; Description:            Returns the requested property or an array of all properties
;                            for the specified file.
; Syntax:                _GetFileProperty( $sPath, optional $sProp )
; Parameter(s):        $sPath -    Path and filename of the file to query
;                            $sProp -    (optional) Name of property to return
;                                        if not specified will return array of all properties
; Requirement(s):        AutoIt 3.2 or higher
; Return Value(s):    On Success - Returns string value of property OR
;                                             Returns 2 dimensional array (property name,value)
;                            On Failure - Returns nothing
;                                             @error = 1 - file does not exist
;                                             @error = 2 - unable to get property
; Author(s):            Sean Hart (autoit AT hartmail DOT ca)
;                            (idea from GetExtProperty by Simucal, thanks)
; Note(s):                Special 
;
;===============================================================================
Func _GetFileProperty($sPath, $sProp = "")
    ; Declare local variables
    Local $sFile, $sDir, $oShell, $oDir, $oFile, $i, $count, $aProps[1][3]
    
    ; Init counter used for array of properties
    $count = 0
    
    ; Check file exists first
    If Not FileExists($sPath) Then
        SetError(1)
        Return
    Else
        ; Pull file name and directory from full file path
        $sFile = StringTrimLeft($sPath, StringInStr($sPath, "\", 0, -1))
        $sDir = StringTrimRight($sPath, (StringLen($sPath) - StringInStr($sPath, "\", 0, -1)))
        
        ; Create required objects
        $oShell = ObjCreate("shell.application")
        $oDir = $oShell.NameSpace($sDir)
        $oFile = $oDir.Parsename($sFile)
        
        ; Loop through 99 possible property numbers (allows for future additions to property fields)
        For $i = 0 to 99
            ; If no property specified then add to array
            If ($sProp = "") Then
                ; Only add if property name is not blank
                If ($oDir.GetDetailsOf($oDir.Items, $i) <> "") Then
                    ; Increase counter and redimension array
                    $count = $count + 1
                    ReDim $aProps[$count + 1][3]
                    
                    ; Add property name and value to array
                    $aProps[$count][1] = $oDir.GetDetailsOf($oDir.Items, $i)
                    $aProps[$count][2] = $oDir.GetDetailsOf($oFile, $i)
                EndIf
                
            ; If property name matches property being requested, return value
            ElseIf $oDir.GetDetailsOf($oDir.Items, $i) = $sProp Then
                Return $oDir.GetDetailsOf($oFile, $i)
            EndIf
        Next
        
        ; If array was populated return array, otherwise return error 2
        If $count > 0 Then
            Return $aProps
        Else
            SetError(2)
            Return
        EndIf
    EndIf
EndFunc   ;==>_GetFileProperty

P.S. i might have found a bug, tell me if im wrong, else i will post it in bugs fourm.

FileCopy() will NOT create directorys with a trailing space.


MUHAHAHAHAHA

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Some more notes:

Edit: Ipod must be in Disk Mode

Im using a G3 ipod, so make sure all directorys ect are correct before you use my script.

Use at your own risk, i havent had much of a problem with it, excet my ipod has crashed a couple times but i think thats due to over heating. something to watch..

P.S. should you need to know, switch the hold switch on then of and hold the menu and play/pause keys for 8-10 or so seconds untill your ipod reboots (partial reset, you dont loose any music or playlists just reboots the ipod and sets the setttings to default)

Edited by smstroble

MUHAHAHAHAHA

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