Old 08-01-2021, 09:14 PM   #1
babag
Human being with feelings
 
Join Date: Nov 2009
Posts: 2,227
Default lua - how to get path for source wav in item

i'm trying to use :

Code:
reaper.InsertMedia(file, mode)
i've had some success but it seems to want the complete path to the source being inserted. i've been able to retrieve and parse the source file name but can't figure out how to get its path.

how do i get the path to a take's source file?

thanks,
babag
babag is offline   Reply With Quote
Old 08-01-2021, 10:19 PM   #2
babag
Human being with feelings
 
Join Date: Nov 2009
Posts: 2,227
Default

this returns the full path including the file name:
Code:
        item     = reaper.GetSelectedMediaItem( 0, 0 )
        take     = reaper.GetActiveTake( item )
        source   = reaper.GetMediaItemTake_Source( take )
        filename = reaper.GetMediaSourceFileName(source, "")
so the new question would be, how to separate the path from the filename? either that or maybe there's another way that just returns the path without the filename?

thanks,
babag
babag is offline   Reply With Quote
Old 08-01-2021, 10:26 PM   #3
mpl
Human being with feelings
 
mpl's Avatar
 
Join Date: Oct 2013
Location: Moscow, Russia
Posts: 3,960
Default

Code:
function GetParentFolder(dir) return dir:match('(.*)[%\\/]') end
mpl is offline   Reply With Quote
Old 08-02-2021, 11:24 AM   #4
babag
Human being with feelings
 
Join Date: Nov 2009
Posts: 2,227
Default

edit:
got it! but it leaves the last / off. is it possible to include it? (i'm on linux, btw.)


thanks, mpl! this looks very helpful but i can't figure out how to use it. i'm terrible at scripting. (i'm on linux, btw, if it makes any difference to the slashes and backslashes.

thanks again,
babag

Last edited by babag; 08-02-2021 at 06:10 PM.
babag 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 05:23 PM.


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