Old 10-19-2018, 04:19 AM   #1
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,458
Default GetProjectPath() returns recording path?

Hello!

GetProjectPath() seems to return the recording path. So in my case it returnds (project path)/Audio



Is it possible to get just the (project path)?

Thanks!
__________________
Most of my scripts can be found in ReaPack.
If you find them useful, a donation would be greatly appreciated! Thank you! :)

Last edited by amagalma; 10-19-2018 at 05:18 AM.
amagalma is offline   Reply With Quote
Old 10-19-2018, 05:42 AM   #2
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,629
Default

Maybe with EnumProjects(), which gives you the path(and filename) of the current project-file, after the project has been saved. This is usually also the path to the project.

Although, this might be a problem, when someone saves the project-file itself somewhere else, while having the "project-assets" at a different place, but this should be a rare problem, I suppose...
If that's the case, using the returned path of GetProjectPath() and getting rid of the last directory in it(in your case "/Audio", in most other cases "/Recording") should lead to the third possible projectfolder.

Using GetProjectPath() and EnumProjects() both should be good enough in most cases.


Management summary:
EnumProject() - the path to the RPP-File and often the projectpath
GetProjectPath() - the recording directory and, if you get rid of the last folder in the returned project-path-string, the other possible project-folder
__________________
Use you/she/her.Ultraschall-Api Lua Api4Reaper - Donate, if you wish

On vacation for the time being...
Meo-Ada Mespotine is offline   Reply With Quote
Old 10-19-2018, 06:31 AM   #3
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,458
Default

Thanks mespotine!



I found out that GetProjectPath() returns the actual project path if the project is not saved, but returns the recording path if the project is saved! :S


So to get the project path one should do this:
Code:
function GetCurrentProjPath()
 local _, projfn = reaper.EnumProjects( -1, "" )
  if projfn == "" then
    return reaper.GetProjectPath("")
  else
    return string.match(projfn, ".+\\")
  end
end

path = GetCurrentProjPath()
__________________
Most of my scripts can be found in ReaPack.
If you find them useful, a donation would be greatly appreciated! Thank you! :)
amagalma is offline   Reply With Quote
Old 10-19-2018, 09:53 AM   #4
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,629
Default

Quote:
I found out that GetProjectPath() returns the actual project path if the project is not saved, but returns the recording path if the project is saved! :S
Oh, didn't know that tiny little detail, will add that to my Reaper-API-docs right away

May I use your function in my function-collection, that I'm currently working on? Properly credited of course...
__________________
Use you/she/her.Ultraschall-Api Lua Api4Reaper - Donate, if you wish

On vacation for the time being...
Meo-Ada Mespotine is offline   Reply With Quote
Old 10-19-2018, 11:22 AM   #5
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,458
Default

Yes, sure!
__________________
Most of my scripts can be found in ReaPack.
If you find them useful, a donation would be greatly appreciated! Thank you! :)
amagalma 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 08:17 AM.


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