here an example from SKAN
( for test select a folder with a few MP3-files )
;---------- selectfolder with MP3-files -------------------
PRESELECT=C:\M_MUSIC\ ;--- search MP3 from here
FileSelectFolder,MF,%PRESELECT%,,Select a folder with MP3
if MF=
return
SplitPath,MF, name, dir, ext, name_no_ext, drive
F1=%name_no_ext%.txt
ifexist,%f1%
filedelete,%f1%
Splashimage,,b w600 h80 x100 Y400 CWteal m9 b fs10 zh0,Read folder=`n%mf%`n write MP3-file_time to text-file=`n%f1%
Loop, %mf%\*.mp3, 0, 1
{
aa=
aa:=GetAudioDuration7(a_loopfilefullpath)
stringsplit,b,aa,`;
SplitPath,a_loopfilefullpath, name, dir, ext, name_no_ext2, drive
c .= name "=" b1 "`r`n"
}
Splashimage,off
Fileappend,%c%`r`n,%f1%
run,%f1%
return
;---------- function MP3 duration SKAN ----------------
GetAudioDuration7(mFile) {
VarSetCapacity( Durn,16,32 )
DllCall( "winmm.dll\mciSendStringA", Str,"open " """" mFile """" " Alias MP3" , UInt,0, UInt,0, UInt,0 )
DllCall( "winmm.dll\mciSendStringA", Str,"status MP3 length", Str,Durn, UInt,16, UInt,0 )
DllCall( "winmm.dll\mciSendStringA", Str,"close MP3", UInt,0, UInt,0, UInt,0 )
StringTrimRight,st,durn, 3
tt:=st
Time := 1601
Time += %st%,S
FormatTime, mmss, %time%, mm:ss
Return Round( st//3600 ) ":" mmss ";" tt
}
return
;=============================================
this creates a formatted text and a m3u-file at desktop
modified=20121124
;------- AHK_Basic XP ---
;------- tagx MP3x datecalculationx datex timex M3ux mp3durationx linepaddingx ----------
;-- it needs time to read mm:ss from MP3-files so don't select folder with to many MP3-files
;-- select folder with MP3-files , creates a formatted text-file ,show nr/filename/h:mm:ss
;-- create also M3u-file at desktop if needed -------
;=======================================================
#SingleInstance, Force
SetWorkingDir %A_ScriptDir%
transform,P,chr,32 ;-- space
transform,k,chr,45 ;-- line > ---
maxchar:=80 ;-- maximal filename lenght
PRESELECT=C:\M_MUSIC\ ;--- search MP3 from here
FileSelectFolder,MF,%PRESELECT%,,Select a folder with MP3
if MF=
return
SplitPath,MF, name, dir, ext, name_no_ext, drive
F1=%A_desktop%\%name_no_ext%.txt
ifexist,%f1%
filedelete,%f1%
t1=5
t2:=0
t3=8
i=0
;-- check maximal length of filename
Splashimage,,b w600 h50 x100 Y400 CWsilver m9 b fs10 zh0,Searching for MP3-files in folder=`n%mf%
Loop, %mf%\*.mp3, 0, 1
{
i++
stringlen,L2,a_loopfilename
if (T2<L2)
T2:=(L2)
}
if (T2=0)
{
Splashimage,off
msgbox, 262208,MP3-Info, No MP3-Files found
exitapp
}
if (i>100)
{
Splashimage,off
msgbox, 262436,MP3-Info,To many songs ( %i% ) selected`nIt has %i% songs which needs time`nWant you continue ?
IfMsgBox, No
return
}
;--- maximal lenght from filename-no-ext --
T2:=(T2-3) ;-- minus extension
if (T2>maxchar)
T2:=maxchar
b2:=0
b3:=0
Splashimage,off
sleep,500
Splashimage,,b w600 h80 x100 Y400 CWteal m9 b fs10 zh0,Read folder=`n%mf%`n write MP3-file_time to text-file=`n%f1%
Loop, %mf%\*.mp3, 0, 1
{
aa=
a1=
a2=
a3=
b2=
aa:=GetAudioDuration7(a_loopfilefullpath)
stringsplit,b,aa,`;
SplitPath,a_loopfilefullpath, name, dir, ext, name_no_ext2, drive
a1:= LP(a_index,t1,P,"R")
a2:= LP(name_no_ext2,t2,P,"L")
stringmid,a2,a2,1,maxchar
a3:= LP(b1,t3,P,"R")
c .= a1 "| " a2 "|" a3 "`r`n"
b3:=(b2+b3)
}
sleep,1000
Splashimage,off
;-- line lenght > ------------
y=
z:=(t1+t2+t3+3)
Loop,%z%
y .= k ;< line ------
;--- total-time ---------------
Time := 1601
Time += %b3%,S
FormatTime, b3x, %time%, mm:ss
bx:=Round( b3//3600 ) ":" b3x
t4:=(t2+t3+2)
bx:=LP(bx,t4,P,"R")
fileappend,%name_no_ext%`r`n%y%`r`n%c%%y%`r`n%a1% %bx%,%f1%
run,%f1%
c=
;--- create also M3u at desktop (?) if needed -----------
F2=%A_desktop%\%name_no_ext%.m3u
ifexist,%f2%
filedelete,%f2%
setworkingdir,%MF%
runwait,%comspec% /c dir /b /s *.mp3 >"%F2%",,hide
;run,%f2%
exitapp
;---------- function MP3 duration SKAN ----------------
GetAudioDuration7(mFile) {
VarSetCapacity( Durn,16,32 )
DllCall( "winmm.dll\mciSendStringA", Str,"open " """" mFile """" " Alias MP3" , UInt,0, UInt,0, UInt,0 )
DllCall( "winmm.dll\mciSendStringA", Str,"status MP3 length", Str,Durn, UInt,16, UInt,0 )
DllCall( "winmm.dll\mciSendStringA", Str,"close MP3", UInt,0, UInt,0, UInt,0 )
StringTrimRight,st,durn, 3
tt:=st
Time := 1601
Time += %st%,S
FormatTime, mmss, %time%, mm:ss
Return Round( st//3600 ) ":" mmss ";" tt
}
;---- function linepadding from user bobo -------
LP(String,FieldLen,ToAppend,Justification)
{
StringLen, StringLen, String
LCnt := FieldLen-StringLen
Loop, % LCnt
Appended := (Appended . ToAppend)
If Justification = R
Return (Appended . String)
If Justification = L
Return (String . Appended)
}
return
;=================== end script ==================