Friday, January 19, 2018

#1 2017-12-11 10:52:28 pm

DarthAztek
Member
Registered: 2016-12-07
Posts: 21

Embedding a file into an AS app for duplication?

This is more a theoretical question more than anything, so I thought I'd pose it here.

Let's say I have a file "_disclaimer.txt" that is used repeatedly when closing out a project, rather than having it sit in a folder on my desktop and having the script be dependent on that file being there to copy, paste, prepend/rename, is it possible to embed said file within the app's packaged contents to do the same thing?

Offline

 

#2 2017-12-11 11:30:56 pm

Shane Stanley
Member
From:: Australia
Registered: 2002-12-07
Posts: 5231

Re: Embedding a file into an AS app for duplication?

Sure. Put it in Contents/Resources and refer to it like this:

Applescript:

set theFile to path to resource "_disclaimer.txt"


Shane Stanley <sstanley@myriad-com.com.au>
www.macosxautomation.com/applescript/apps/

Offline

 

#3 2018-01-04 02:34:39 pm

DarthAztek
Member
Registered: 2016-12-07
Posts: 21

Re: Embedding a file into an AS app for duplication?

Somehow I'm getting an error that it can't find the asset. I have the path to resource happening inside a handler, could that be the problem (meaning that should reside outside of a handler)?

Offline

 

#4 2018-01-04 02:53:06 pm

wch1zpink
Member
Registered: 2011-08-20
Posts: 1

Re: Embedding a file into an AS app for duplication?

Applescript:

set theResource to (path to me as string) & "Contents:Resources:_disclaimer.txt"

Offline

 

#5 2018-01-04 05:25:55 pm

Shane Stanley
Member
From:: Australia
Registered: 2002-12-07
Posts: 5231

Re: Embedding a file into an AS app for duplication?

DarthAztek wrote:

Somehow I'm getting an error that it can't find the asset. I have the path to resource happening inside a handler, could that be the problem (meaning that should reside outside of a handler)?



No, it shouldn't make any difference.


Shane Stanley <sstanley@myriad-com.com.au>
www.macosxautomation.com/applescript/apps/

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)