• 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
Re: saving front window using osascript...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: saving front window using osascript...


  • Subject: Re: saving front window using osascript...
  • From: Fons Rademakers <email@hidden>
  • Date: Wed, 21 Nov 2007 15:17:42 +0100
  • Keywords: CERN SpamKiller Note: -51 Charset: west-latin
  • Keywords: CERN SpamKiller Note: -51 Charset: west-latin
  • Organization: CERN

Hi Philip,

my problem is with what osascript is doing with the text when setting it to a text document. It breaks lines at "\n", not the byte value \n. I tried also to change the Applescript's text separation char to 10 or 13 but that did not help here.

Cheers, Fons.


Philip Aker wrote:
On 2007-11-20, at 07:10, Fons Rademakers wrote:

#!/bin/sh
# Removes trailing blanks (spaces and tabs) and save to file.

osascript &lt;&lt; ENDOFSCRIPT
tell application "Xcode"
set myFile to associated file name of front window
set textDocuments to text documents
repeat with i in textDocuments
if path of i is myFile then
set orgText to text of i
set text of i to do shell script "echo " & quoted form of orgText & " | tr '\r' '\n' | perl -pe 's/[\t ]+$//g'"
save i
end if
end repeat
end tell
ENDOFSCRIPT

Hey Fons,

Here's a different approach to your situation. I think you might be able to adapt. There are a few factors involved that could subvert the process. One is that I have my Xcode preferences set to save always. Another is that there could possibly be some issues with Spotlight hanging on to altered files -- this was a known problem in 10.4 and I don't know if it's been addressed in 10.5. One way to work around it is to tell the Finder to 'update' the files after they've been closed/changed and maybe insert a 'delay' afterwards in the script. Here I get every file in target 1. You can branch on the file type or the subset which would be the paths of the current text documents.

tell application "Xcode"
close (every text document) saving yes
set flist to {}
tell active project document
tell target 1
set flist to real path of file reference of every build file
end tell
end tell
-- do perl stuff, update, delay
open flist
end tell

Philip Aker
echo email@hidden <mailto:email@hidden>@nl | tr a-z@. p-za-o.@


-- Org: CERN, European Laboratory for Particle Physics. Mail: 1211 Geneve 23, Switzerland E-Mail: email@hidden Phone: +41 22 7679248 WWW: http://fons.rademakers.org Fax: +41 22 7669640 _______________________________________________ Do not post admin requests to the list. They will be ignored. Xcode-users mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
  • Follow-Ups:
    • Re: saving front window using osascript...
      • From: Philip Aker <email@hidden>
References: 
 >saving front window using osascript... (From: Fons Rademakers <email@hidden>)
 >Re: saving front window using osascript... (From: Rick Ballard <email@hidden>)
 >Re: saving front window using osascript... (From: Fons Rademakers <email@hidden>)
 >Re: saving front window using osascript... (From: Rick Ballard <email@hidden>)
 >Re: saving front window using osascript... (From: Fons Rademakers <email@hidden>)
 >Re: saving front window using osascript... (From: Rick Ballard <email@hidden>)
 >Re: saving front window using osascript... (From: Fons Rademakers <email@hidden>)
 >Re: saving front window using osascript... (From: Philip Aker <email@hidden>)

  • Prev by Date: Re: saving front window using osascript...
  • Next by Date: Re: Problem loading IB plugin [solved]
  • Previous by thread: Re: saving front window using osascript...
  • Next by thread: Re: saving front window using osascript...
  • Index(es):
    • Date
    • Thread