• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Files and Aliases
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Files and Aliases


  • Subject: Files and Aliases
  • From: Gil Dawson <email@hidden>
  • Date: Tue, 11 Mar 2014 13:31:31 -0700

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
display dialog ¬
"Output file y.scc already exists." & return & ¬
"Overwrite it?" buttons {"Overwrite it", "Cancel"} ¬
default button 2
if button returned of result is "Cancel" then ¬
error "Quitting now."
end if
end tell

log "OutFileName=" & OutFileName -->
set OutFile to file OutFileName -->

Those last two lines generate
(*OutFileName=MBProHD:Users:gil:Desktop: 2 Enigma wFBs y.scc*)
and
error "Can’t get file \"MBProHD:Users:gil:Desktop: 2 Enigma wFBs y.scc\"." number -1728 from file "MBProHD:Users:gil:Desktop: 2 Enigma wFBs y.scc"

--Gil
 _______________________________________________
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

  • Follow-Ups:
    • Re: Files and Aliases
      • From: Christopher Stone <email@hidden>
    • Re: Files and Aliases
      • From: Shane Stanley <email@hidden>
    • Re: Files and Aliases
      • From: "koenig.yvan" <email@hidden>
  • Prev by Date: Re: Scriptable multi-clipboard utility?
  • Next by Date: Re: Files and Aliases
  • Previous by thread: Re: build a list of mailboxes
  • Next by thread: Re: Files and Aliases
  • Index(es):
    • Date
    • Thread