#include-once #include #include #include #include #include Global $aFileList Global $sFileSelectFolder = FileSelectFolder("WHERE ARE THE MP3s?", "") Global $sFileDestinationFolder = FileSelectFolder("DESTINATION", "") Global $Music Global $Audiobooks Global $i=0 Global $n=1 Global $isMP3=0 $totalfiles=0 Global $FIRSTAuthor="" Global $FIRSTBook="" Global $SECONDAuthor="" Global $SECONDBook="" ;$FO_APPEND + ;*************************** Open the CSV file $DestFile=$sFileDestinationFolder&"\MP3 Book List.csv" $hfileopen = FileOpen($DestFile, $FO_OVERWRITE + $FO_CREATEPATH) ;*************************** Create an array containing all file names _Listfile() ;MsgBox($MB_SYSTEMMODAL, "", $aFilelist[0]) ;*************************** find the first MP3 file While $isMP3=0 $N=$N+1 $IsMP3 = StringInStr($aFilelist[$n], ".mp3") WEnd ;***************** create the full file path $Filename = $sFileSelectFolder & "\"& ($aFilelist[$n]) ;***************** Read the Tags $sFileTagInfo = _ID3ReadTag($Filename) ;**************** Assign the ALBUM and AUTHOR (Artist) tags to variables $FIRSTBook=_ID3GetTagField("TALB") $FIRSTAuthor=_ID3GetTagField("TPE1") ;MsgBox($MB_SYSTEMMODAL, "", $FIRSTAuthor,2) ; ****************** For every file in the structure:- For $i = 1 To $aFilelist[0] ;******************** Is the file an MP3 file? $IsMP3 = StringInStr($aFilelist[$i], ".mp3") If $isMP3<>0 Then ; So StringInStr returns an integer IF the string is found ; ***** Create the full file path for THIS file. $Filename = $sFileSelectFolder & "\"& ($aFilelist[$i]) ;***** Read the Tags to different variables. $sFileTagInfo = _ID3ReadTag($Filename) $SECONDBook=_ID3GetTagField("TALB") $SECONDAuthor=_ID3GetTagField("TPE1") ;MsgBox($MB_SYSTEMMODAL, "", $SECONDAuthor,2) ;MsgBox($MB_SYSTEMMODAL, "", $SECONDBook,2) Endif If $SECONDBook<>$FIRSTBook Then ;*************** compare the tags found initially with the tags found now ; ************** If the tags are different, write the first set of tags to the CSV file FileWriteLine($hFileOpen, $FIRSTAuthor& "**" & $FIRSTBook) ;********** copy the tags found now over the first set of tags. $FIRSTAuthor=$SECONDAuthor $FIRSTBook=$SECONDBook ; ************* display something to reassure the user that something is happening ToolTip($FIRSTBook, 200, 200) ;MsgBox($MB_SYSTEMMODAL, "", $aFileList[$i],1) EndIf $isMP3=0 Next FileWriteLine($hFileOpen, $FIRSTAuthor& "**" & $FIRSTBook) FileClose($hfileopen) Func _Listfile() ; List all the files and folders in the desktop directory using the default parameters and return the full path. Global $aFileList = _FileListToArrayRec($sFileSelectFolder, "*", $FLTAR_FILESFOLDERS, $FLTAR_RECUR, $FLTAR_SORT) If @error = 1 Then MsgBox($MB_SYSTEMMODAL, "", "Path was invalid.") Exit EndIf If @error = 4 Then MsgBox($MB_SYSTEMMODAL, "", "No file(s) were found.") Exit EndIf ; Display the results returned by _FileListToArray. ;_ArrayDisplay($aFileList, "$aFileList") EndFunc ;==>Listfile