Old 04-16-2019, 03:06 AM   #1
dsyrock
Human being with feelings
 
dsyrock's Avatar
 
Join Date: Sep 2018
Location: China
Posts: 142
Default How to load a bunch of files automatically with script?

I don't know if it is a crazy idea.

Let's say there are a bunch of files sitting in the folder: E:\testing\

And their filenames are something like:

reaper-01.txt

reaper-02.txt

reaper-abc.txt

reaper-omg.txt

.
.
.
.

reaper-apc089abq03.txt

And if I want to import these "reaper-***.txt" files into a script, is it possible?

I'm thinking about using reaper.GetUserFileNameForRead, selecting one of them, So that I can get the path "E:\testing" and part of the filename "reaper-???.txt"

Then, I stuck in here. How can I get all of those file without missing any of them? Or can lua get a list of all files in a folder?

Last edited by dsyrock; 04-16-2019 at 03:12 AM.
dsyrock is offline   Reply With Quote
Old 04-16-2019, 03:36 AM   #2
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 5,789
Default

There is APi functions to Enumerate Files and Enumerate folders,


Also there is a js_extension function mike the one you use but for selecting folders.


I let you inspect the doc the find their names :P
X-Raym is offline   Reply With Quote
Old 04-16-2019, 04:43 AM   #3
dsyrock
Human being with feelings
 
dsyrock's Avatar
 
Join Date: Sep 2018
Location: China
Posts: 142
Default

Quote:
Originally Posted by X-Raym View Post
There is APi functions to Enumerate Files and Enumerate folders,


Also there is a js_extension function mike the one you use but for selecting folders.


I let you inspect the doc the find their names :P
Wow thanks X-Raym. EnumerateFiles is exactly the api I want, and didn't know that before.
dsyrock is offline   Reply With Quote
Old 04-16-2019, 09:07 AM   #4
mespotine
Human being with feelings
 
mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig, Germany
Posts: 1,199
Default

Or you're using my Ultraschall API

Get all filenames in a directory:
https://mespotin.uber.space/Ultrasch...ilenamesInPath

Get all directories in a directory:
https://mespotin.uber.space/Ultrasch...ectoriesInPath

Get all files and directories, including the ones in subdirectories:
https://mespotin.uber.space/Ultrasch...Subdirectories


And to read the file in a comfortable way, use:
https://mespotin.uber.space/Ultrasch...l#ReadFullFile
__________________
Ultraschall-API - a Lua-functions-library4Reaper: https://forum.cockos.com/showthread....98#post2067798
Reaper Internals - Developerdocs4Reaper: https://forum.cockos.com/showthread.php?t=207635
mespotine is online now   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 09:55 AM.


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