Page 1 of 1

File Directory/Data

Posted: Fri Jul 21, 2017 6:42 pm
by anthonytsb5
Is there a way to get the name of the file currently being worked on and the directory it is stored in?

I am working on a camera manager so I can just have a series of buttons to switch between camera views and am planning on storing the data in the same location as the file. All the examples I found use localize to save it in the script directory which seems problematic to me if you're ever handing off files.

Re: File Directory/Data

Posted: Fri Jul 21, 2017 7:10 pm
by synthsin75
moho.document:Path()

This will return the current file's complete path name. You can then remove the file name (moho.document:Name()) to find the directory.

Re: File Directory/Data

Posted: Fri Jul 21, 2017 8:01 pm
by anthonytsb5
Once again you are my personal hero, synthsin75.

Re: File Directory/Data

Posted: Fri Jul 21, 2017 9:16 pm
by synthsin75
Glad to help. :wink:

Re: File Directory/Data

Posted: Sat Jul 22, 2017 7:27 am
by hayasidist
anthonytsb5 wrote:Is there a way to get the name of the file currently being worked on and the directory it is stored in?

I am working on a camera manager so I can just have a series of buttons to switch between camera views and am planning on storing the data in the same location as the file.
synthsin75 wrote:u can then remove the file name (moho.document:Name()) to find the directory.
or simply append something like camera to the end ==> xxx.mohocamera or strip off the moho and replace it ==> xxx.camera

and .. I'd love to see this script when it's finished!

Re: File Directory/Data

Posted: Sat Jul 22, 2017 7:37 am
by synthsin75
hayasidist wrote:or simply append something like camera to the end ==> xxx.mohocamera or strip off the moho and replace it ==> xxx.camera
Good point. Doesn't matter what the extension is, so long as your script knows the one to accept/look for.

Re: File Directory/Data

Posted: Sat Jul 22, 2017 7:54 am
by hayasidist
a further thought -- if the camera stuff is only for the one project you might like to consider using MohoDoc:Metadata() see http://www.mohoscripting.com/index.php? ... ta&id=1014 rather than a file -- an example of managing such data is in http://www.mohoscripting.com/index.php? ... ta&id=1122

Re: File Directory/Data

Posted: Mon Jul 24, 2017 12:31 am
by anthonytsb5
hayasidist wrote:and .. I'd love to see this script when it's finished!
Thanks, hayasidist. One last hurdle on the script but I'm hoping to upload it tonight/tomorrow so folks can take a look at take into into production on a short I'm working on this week.