• 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: Philip Aker <email@hidden>
  • Date: Wed, 21 Nov 2007 05:55:49 -0800

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@nl | tr a-z@. p-za-o.@

 _______________________________________________
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: Fons Rademakers <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>)

  • Prev by Date: How do I escape accented characters for the shell?
  • Next by Date: Re: saving front window using osascript...
  • Previous by thread: Re: saving front window using osascript...
  • Next by thread: Re: saving front window using osascript...
  • Index(es):
    • Date
    • Thread