To filter non existing files i used two different methods but i cannot find why one gives a wrong result (4 files ).
Is it allowed to store the result of the filtering in the same object name ?
m:=exist_mp3(m)
Code: Select all
setworkingdir,%A_ScriptDir%
loop 6
filedelete ,file%A_Index%.mp3
sleep 1000
; create 6 files for testing
loop 6
FileAppend, ldmdmd ,file%A_Index%.mp3
m:=get_mp3(A_ScriptDir)
; remove 3 files for testing
loop 3
FileDelete, file%A_Index%.mp3
notexist_mp3(m)
for k,v in m
list .=k " " v "`n"
msgbox notexist`n%list%
m:=exist_mp3(m)
list:=""
for k,v in m
list .=k " " v "`n"
msgbox exist`n%list%
notexist_mp3(z){
loop, % z.length()
if !FileExist(z[A_Index])
z.removeat(A_Index)
}
exist_mp3(z){
x:={}
loop, % z.length()
if FileExist(z[A_Index])
x.push(z[A_Index])
return x
}
get_mp3(dir){
z:={}
Loop, %dir%\*.mp3
z.push(A_LoopFileFullPath)
return z
}