Walk a directory/Recursively: Difference between revisions
Content added Content deleted
Line 1,360: | Line 1,360: | ||
=={{header|LiveCode}}== |
=={{header|LiveCode}}== |
||
<lang LiveCode>function |
<lang LiveCode>function pathsForPatternAndDirectory pPattern, pDirectory |
||
set the defaultFolder to pDirectory |
|||
⚫ | |||
filter the files with pPattern |
|||
if fileExt(fi) = ext then |
|||
⚫ | |||
put the longfilepath of fi & cr after fileList |
|||
⚫ | |||
end if |
|||
end repeat |
|||
⚫ | |||
filter the folders without ".." |
|||
if di is not "." and di is not ".." then |
|||
⚫ | |||
⚫ | |||
put pathsForPatternAndDirectory(pPattern, pDirectory & slash & tFolder) after tPaths |
|||
end if |
|||
end repeat |
|||
filter fileList without empty |
|||
return tPaths |
|||
end pathsForPatternAndDirectory |
|||
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> |
|||
=={{header|Lua}}== |
=={{header|Lua}}== |