Re: Files and Aliases
Re: Files and Aliases
- Subject: Re: Files and Aliases
- From: "koenig.yvan" <email@hidden>
- Date: Tue, 11 Mar 2014 22:37:50 +0100
I'm getting a little confused...
I wish to generate a file name into which I will ask TextWrangler to Save some manipulated text.
The TextWrangler .sdef says that it needs an alias for the destination for its Save operation:
save v : Save a window or document. save specifier : the object to save [to alias] : file in which to save the window’s contents ...
I can't figure out how to create an alias to a file that's not created yet.
What does work is
set OutFile to POSIX file ...(and specify the destination in a text literal)
but I want to compute the destination.
I've tried
set OutFileName to (generate the file path as text) set OutFile to alias OutFileName
but that gets the error "File wasn't found".
I also tried
set OutFileName to (generate the file path as text) set OutFile to file OutFileName
which got the error "Can't get file".
Am I missing something obvious?
Here's my code that doesn't work:
set InFile to choose file with prompt ¬ "Select an input file." of type "scc"
tell application "Finder" set InFileName to (name of InFile) as string set OutFileName to ("" & container of InFile) ¬ & (text 1 through -5 of InFileName) ¬ & " y.scc" if exists OutFileName then
OutFileName is a string If there is no file with this pathname you can't get it as alias So just edit this late instruction as
if exists file OutFileName then
Yvan KOENIG (VALLAURIS, France) mardi 11 mars 2014 22:35:47
|
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden