Walk a directory/Recursively: Difference between revisions

→‎{{header|LiveCode}}: restored previous, made latest/current "alternative"
(→‎{{header|LiveCode}}: corrected what I think is the accidental vandalism of deleting Lua entry)
(→‎{{header|LiveCode}}: restored previous, made latest/current "alternative")
Line 1,360:
 
=={{header|LiveCode}}==
<lang LiveCode>function recurDir dir, ext
set the defaultFolder to dir
repeat for each line fi in the files
if fileExt(fi) = ext then
put the longfilepath of fi & cr after fileList
end if
end repeat
repeat for each line di in the folders
if di is not "." and di is not ".." then
put recurDir((dir & slash & di), ext) & cr after fileList
end if
end repeat
filter fileList without empty
return fileList
end recurDir
 
function fileExt f
set the itemdel to "."
return the last item of f
end fileExt</lang>
Example
<lang LiveCode>put recurDir(the home folder & slash & "music", "mp3")</lang>
Output
<pre>... /Users/xxx/music/albumx/trackx.mp3
/Users/xxx/music/albumx/trackx2.mp3
/Users/xxx/music/albumy/tracky.mp3 ...</pre>
 
===alternative===
<lang LiveCode>function pathsForPatternAndDirectory pPattern, pDirectory
set the defaultFolder to pDirectory
7,804

edits