Old 07-06-2015, 11:04 AM   #1
mpl
Human being with feelings
 
mpl's Avatar
 
Join Date: Oct 2013
Location: Moscow, Russia
Posts: 3,960
Default Get list of files in folder (LUA)

Is it possible? Maybe os.execute or something?
mpl is offline   Reply With Quote
Old 07-06-2015, 11:15 AM   #2
Xenakios
Human being with feelings
 
Xenakios's Avatar
 
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 8,062
Default

Looks like it's possible but messy...(I have no idea if for example LuaFileSystem will work with Reaper's Lua.)

http://stackoverflow.com/questions/1...rectory-in-lua

http://stackoverflow.com/questions/5...ctory-in-a-lua
__________________
I am no longer part of the REAPER community. Please don't contact me with any REAPER-related issues.
Xenakios is offline   Reply With Quote
Old 07-06-2015, 11:15 AM   #3
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,668
Default

Found this from my computer - I have probably copied it from http://stackoverflow.com)

(show all filenames in current script path)
Code:
function msg(m)
  return reaper.ShowConsoleMsg(tostring(m) .. "\n")
end

function get_script_path()
  local info = debug.getinfo(1,'S');
  local script_path = info.source:match[[^@?(.*[\/])[^\/]-$]]
  return script_path
end

-- get "script path"
script_path = get_script_path()

-- Lua implementation of PHP scandir function
function scandir(directory)
    local i, t, popen = 0, {}, io.popen
    for filename in popen('dir "'..directory..'" /b'):lines() do
        msg(filename)
        i = i + 1
        t[i] = filename
    end
    return t
end

file_table = scandir(script_path)
("cmd dialog" seems to appear - don't know if there's a way to prevent that)
spk77 is offline   Reply With Quote
Old 07-06-2015, 01:13 PM   #4
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 9,875
Default

Oh sure, this can help

I had an idea which would involved that.
But I didn't need the script anymore ^^
X-Raym is offline   Reply With Quote
Old 11-21-2017, 03:46 AM   #5
modraw
Human being with feelings
 
modraw's Avatar
 
Join Date: Oct 2017
Posts: 27
Default

Hey, thanks for the snippet! Very usefull. I'm scratching my head aroung to find a way to list all .wav files in a folder AND its subfolder.

For filtering .wav files I'll try to use this :
Code:
for filename in popen('findstr /m /c:"' .. str .. '" ' .. path):lines() do
But for subfolders the popen action is a bit complexe for me and can't find "documentation for dummy" on that

Thanks!
modraw is offline   Reply With Quote
Old 11-21-2017, 03:56 AM   #6
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 9,875
Default

@modraw
hi !

The trick is to split the file name or the path with a certain pattern to extract the extension, and just make a simple string comparison with it to filter your table.

Notes that since this post, REAPER API has dedicated function for looking into directory and subdirectories :P (since v5.02)
X-Raym is offline   Reply With Quote
Old 11-21-2017, 04:27 AM   #7
modraw
Human being with feelings
 
modraw's Avatar
 
Join Date: Oct 2017
Posts: 27
Default

Thanks !!
modraw is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 11:45 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.