|
|
|
03-09-2017, 09:53 PM
|
#1
|
Human being with feelings
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
|
Script: Create action to open a file...
As per @hopi's request here: http://forum.cockos.com/showthread.php?t=189037
Allows you to browse for a file (or a folder) and then generates a ReaScript to open it in the appropriate app. Could be used for folders you frequently access, or filling a toolbar with shortcuts to the manuals for your favorite plugins, etc, etc.
Available on ReaPack, or manually: Lokasenna_Create action to open a file... .lua
Enjoy.
|
|
|
03-09-2017, 11:55 PM
|
#2
|
Human being with feelings
Join Date: Oct 2008
Location: Right Hear
Posts: 15,618
|
oh no... REALLY? Holy Smoke.... I'm too gone to try that tonight but I am mucho excited to give that go... you are amazing!!!
|
|
|
03-10-2017, 02:52 AM
|
#3
|
Human being with feelings
Join Date: Jan 2007
Location: mcr:uk
Posts: 3,889
|
Quote:
Originally Posted by Lokasenna
Allows you to browse for a file (or a folder) and then generates a ReaScript to open it in the appropriate app.
|
Ha, show-off!
|
|
|
03-10-2017, 10:00 AM
|
#4
|
Human being with feelings
Join Date: Oct 2008
Location: Right Hear
Posts: 15,618
|
Ok ...so tested and it's pretty insane that it works as it does...
and yet, it makes me ask this:
Can we have one that does the same thing but does not go to the individual file level? In other words, it will just let us choose a given folder to open and save that as a new script?
|
|
|
03-10-2017, 08:59 PM
|
#5
|
Human being with feelings
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
|
Read the first message that pops up.
Reaper doesn't give me a way to pop up a "Choose a folder" dialog. Or a "Save As" dialog, for that matter.
|
|
|
03-10-2017, 09:14 PM
|
#6
|
Human being with feelings
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
|
Updated, automatically adds the new script to the Action List.
|
|
|
03-10-2017, 10:47 PM
|
#7
|
Human being with feelings
Join Date: Oct 2008
Location: Right Hear
Posts: 15,618
|
ummm OK thanks for explaining this....
It is indeed quite amazing that it can open a given file and automatically write the new script...
At the same time it is not all that useful for me to open a 'file'... I need to open a folder... without leaving being inside reaper...
hmmm.... I wonder if it would open a shortcut.... I'll test that in a moment
|
|
|
03-11-2017, 04:55 AM
|
#8
|
Human being with feelings
Join Date: Oct 2015
Posts: 739
|
hopi, just delete filename, and leave only folder path. Then it opens folder.
|
|
|
03-11-2017, 07:10 AM
|
#9
|
Human being with feelings
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
|
Quote:
Originally Posted by sonicowl
hopi, just delete filename, and leave only folder path. Then it opens folder.
|
Like the first message box says.
Seriously though, if the wording there is unclear I'm open to suggestions for a better way to phrase it.
|
|
|
03-11-2017, 12:32 PM
|
#10
|
Human being with feelings
Join Date: Jan 2007
Location: mcr:uk
Posts: 3,889
|
Quote:
Originally Posted by Lokasenna
Updated, automatically adds the new script to the Action List.
|
Now come on, that really is just showing off! For goodness sake man, tone it down. You're making the rest of us look bad!
|
|
|
03-11-2017, 12:39 PM
|
#11
|
Human being with feelings
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
|
Quote:
Originally Posted by IXix
Now come on, that really is just showing off! For goodness sake man, tone it down. You're making the rest of us look bad!
|
It was a suggestion from mpl, but thanks.
|
|
|
03-12-2017, 02:05 AM
|
#12
|
Human being with feelings
Join Date: Oct 2008
Location: Right Hear
Posts: 15,618
|
Keep showing off!
I think I totally misunderstood at first but now I maybe get it...
You guys are saying run the script, then edit the lua it creates by taking out the file name... and that will open the folder.... gotta go test but if that is it, that will suit me just great.
|
|
|
03-12-2017, 09:05 AM
|
#13
|
Human being with feelings
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
|
You can remove the filename in the window that lets you provide an alias for the script.
|
|
|
03-12-2017, 06:15 PM
|
#14
|
Human being with feelings
Join Date: Apr 2010
Location: Turkey/Istanbul
Posts: 1,820
|
Very useful, Thank you so much!
|
|
|
03-17-2017, 07:31 PM
|
#15
|
Human being with feelings
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
|
Small update, courtesy of @mpl. It will now use the filename you select as a suggested alias.
|
|
|
10-24-2017, 04:06 AM
|
#16
|
Human being with feelings
Join Date: Jul 2014
Location: London
Posts: 733
|
Would love to use this, but all the files are greyed out for me. Is this a mac problem?
|
|
|
10-26-2017, 03:35 PM
|
#17
|
Human being with feelings
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
|
I... have no idea.
|
|
|
10-27-2017, 01:17 AM
|
#18
|
Human being with feelings
Join Date: Apr 2011
Posts: 3,451
|
Lokasenna, I hope you don't mind me posting this..
Code:
--[[
Description: Create action to open a file...
Version: 1.2.2
Author: Lokasenna
Donation: https://paypal.me/Lokasenna
Changelog:
Name change for consistency
Links:
Forum Thread http://forum.cockos.com/showthread.php?t=189152
Lokasenna's Website http://forum.cockos.com/member.php?u=10417
About:
Automates the creation of ReaScripts that will open files or folders
in their native app. Handy for shortcuts to plugin manuals, or commonly
used folders, etc.
Note: Due to Reaper limitations, creating a shortcut to a folder equires you
to select a file IN that folder, and then manually erase the filename
from the path. Sorry. :/
--]]
-- Licensed under the GNU GPL v3
local ret, path, csv, alias
reaper.ShowMessageBox("To create an action that opens a folder:\n\n1. Use the next window to select a file in that folder.\n2. Click 'OK'.\n3. Another window will pop up; manually erase the filename there.\n\nThis is a Reaper limitation - sorry for the inconvenience.", "Create action to open a file...", 0)
ret, path = reaper.GetUserFileNameForRead("", "Select a file", "")
if not ret then return 0 end
-- Cheers to @mpl for this.
local num = path:reverse():find('[%/%\\]')
local alias = path:sub(-num + 1) .. " "
--reduced_name = reduced_name:sub(0,-1-reduced_name:reverse():find('%.')) -- cut extension also
ret, csv = reaper.GetUserInputs("Create action to open a file... ", 2, "File/folder path:,File alias:,extrawidth=128", path..","..alias)
if not ret or csv == "" then return 0 end
path, alias = string.match(csv, "([^,]+),([^,]*)")
if not path then return 0 end
local str = "-- Created with Lokasenna_Create action to open a file... .lua\n"
.. 'local path = "' .. path .. '"\n'
.. [[if string.match( reaper.GetOS(), "Win") then]] .. "\n"
.. [[ reaper.ExecProcess('cmd.exe /C start "" "' .. path ..'"', 0)]]
.. "\nelse\n"
.. [[ os.execute('open "" "' .. path)]] .. "\n"
.. "end\n"
.. "reaper.defer(function () end)"
str = string.gsub(str, [[\]], [[\\]])
local info = debug.getinfo(1,'S');
local script_path = info.source:match[[^@?(.*[\/])[^\/]-$]]
local file_name = script_path .. "Open a file - " .. alias .. ".lua"
local file, err = io.open( file_name , "w+")
if not file then
reaper.ShowMessageBox("Couldn't create file:\n" .. file_name .. "\n\nError: " .. tostring(err), "Whoops", 0)
return 0
end
file:write(str)
reaper.ShowMessageBox( "Successfully created file:\n"
.. ( string.len(file_name) > 64 and ( "..." .. string.sub(file_name, -56) )
or file_name),
"Yay!", 0)
io.close(file)
reaper.AddRemoveReaScript( true, 0, file_name, true )
A very slightly modified version.. For Windows, it doesn't open the command prompt. Also, (for any OS) the script doesn't create an undo point in the Undo History
|
|
|
01-23-2018, 12:21 PM
|
#19
|
Human being with feelings
Join Date: Apr 2013
Location: France
Posts: 9,874
|
Just noticed this script... A script which generate a script. Nice concept ^^
|
|
|
08-05-2019, 04:21 AM
|
#20
|
Human being with feelings
Join Date: Jun 2019
Posts: 2,872
|
Can't get this script to work, I can only navigate through the folders but the files are all greyed out.
|
|
|
08-05-2019, 06:33 AM
|
#21
|
Human being with feelings
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
|
Quote:
Originally Posted by Phazma
Can't get this script to work, I can only navigate through the folders but the files are all greyed out.
|
That's strange. What OS?
|
|
|
08-05-2019, 06:40 AM
|
#22
|
Human being with feelings
Join Date: Jun 2019
Posts: 2,872
|
Quote:
Originally Posted by Lokasenna
That's strange. What OS?
|
macOS High Sierra
|
|
|
08-12-2019, 03:52 PM
|
#23
|
Human being with feelings
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
|
Turns out it's a Reaper issue, which should be fixed as of today's prerelease (v5.981+dev0812). You can test that version if you want, or wait a week or two for the next official release - in either case, let me know if the problem doesn't go away.
|
|
|
08-13-2019, 12:26 AM
|
#24
|
Human being with feelings
Join Date: Jun 2019
Posts: 2,872
|
Quote:
Originally Posted by Lokasenna
Turns out it's a Reaper issue, which should be fixed as of today's prerelease (v5.981+dev0812). You can test that version if you want, or wait a week or two for the next official release - in either case, let me know if the problem doesn't go away.
|
Thanks for the info! The creation of the action now works flawlessly, however running the action does not do anything. Could it be that this script has been made for windows?
I have no clue about scripting, however when opening the script I can see it says reaper.GetOS(), "Win" at a certain point.. could this refer to windows?
|
|
|
08-13-2019, 06:30 AM
|
#25
|
Human being with feelings
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
|
It checks to see if the user is on Windows versus Mac so it can use the appropriate terminal command - start on Windows, open on Mac.
Code:
reaper.GetOS(), "Win") and ('start "" "') or ('open "" "')
I could swear I've had a couple of people use it on Mac without any trouble.
- Does it give an error, or just do nothing at all?
- Are you able to find the script it created for the file you chose? The script will be in the same folder as the main script, so ReaScripts/Various/Open a file - ______.lua. If so, open it in a text editor and paste the contents here.
I did just discover that it doesn't work on Linux though. :P
Last edited by Lokasenna; 08-13-2019 at 06:42 AM.
|
|
|
08-13-2019, 10:50 AM
|
#26
|
Human being with feelings
Join Date: Jun 2019
Posts: 2,872
|
It just does nothing at all.
Here is the text from the script it created:
-- Created with Lokasenna_Create action to open a file... .lua
os.execute( ( string.match( reaper.GetOS(), "Win") and ('start "" "') or ('open "" "') ) .. "/Users/mirko/Library/Application Support/REAPER/ Reaper Media/Manuals/USER GUIDE.pdf" )
|
|
|
08-13-2019, 11:02 AM
|
#27
|
Human being with feelings
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
|
What happens if you open a terminal and put in:
Code:
open "" "/Users/mirko/Library/Application Support/REAPER/ Reaper Media/Manuals/USER GUIDE.pdf"
?
|
|
|
08-13-2019, 11:57 AM
|
#28
|
Human being with feelings
Join Date: Jun 2019
Posts: 2,872
|
Quote:
Originally Posted by Lokasenna
What happens if you open a terminal and put in:
Code:
open "" "/Users/mirko/Library/Application Support/REAPER/ Reaper Media/Manuals/USER GUIDE.pdf"
?
|
It opens the finder (home folder) as well as the correct file which it is supposed to open.
|
|
|
02-11-2021, 08:29 AM
|
#29
|
Human being with feelings
Join Date: May 2016
Posts: 681
|
Quote:
Originally Posted by Phazma
It opens the finder (home folder) as well as the correct file which it is supposed to open.
|
Try:
Code:
os.execute('open -a "Preview" "/Users/mirko/Library/Application Support/REAPER/ Reaper Media/Manuals/USER GUIDE.pdf"')
|
|
|
Thread Tools |
|
Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -7. The time now is 02:14 AM.
|