Walk a directory/Recursively: Difference between revisions
Content added Content deleted
Line 1,122: | Line 1,122: | ||
=={{header|LiveCode}}== |
=={{header|LiveCode}}== |
||
⚫ | |||
This implementation only lists folders with files that match the specified pattern (use * to match all). |
|||
set the defaultFolder to dir |
|||
⚫ | |||
⚫ | |||
put dirwalk(d) into fileDirList |
|||
if fileExt(fi) = ext then |
|||
⚫ | |||
put the longfilepath of fi & cr after fileList |
|||
put the files into tmp |
|||
filter tmp with ext |
|||
⚫ | |||
repeat with i = 1 to the number of lines of tmp |
|||
put fd & slash before line i of tmp |
|||
⚫ | |||
put tmp & cr after filelist |
|||
end if |
end if |
||
end repeat |
end repeat |
||
repeat for each line di in the folders |
|||
⚫ | |||
⚫ | |||
⚫ | |||
put recurDir((dir & slash & di), ext) & cr after fileList |
|||
end listfiles |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
end recurDir |
|||
function |
function fileExt f |
||
set the |
set the itemdel to "." |
||
return the last item of f |
|||
⚫ | |||
filter dirlist without ".*" |
|||
filter dirlist without "$*" |
|||
if the number of lines of dirlist > 0 then |
|||
repeat with i = 1 to the number of lines of dirlist |
|||
put d & slash before line i of dirlist |
|||
put dirwalk(line i of dirlist) after dirlist |
|||
end repeat |
|||
⚫ | |||
return dirlist |
|||
⚫ | |||
Example |
Example |
||
<lang LiveCode>put |
<lang LiveCode>put recurDir(the home folder & slash & "music", "mp3")</lang> |
||
Output |
Output |
||
<pre>... /Users/xxx/music/albumx/trackx.mp3 |
<pre>... /Users/xxx/music/albumx/trackx.mp3 |