• 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: Requesting help, please
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Requesting help, please


  • Subject: Re: Requesting help, please
  • From: Brian Christmas <email@hidden>
  • Date: Sun, 24 Jan 2016 21:15:09 +1100

Shane, I did some searching for and found an entry you had helped someone with. I amended my code to the following.

Without the ‘try’ in the looping, I got an error, on .DS_Store, after ‘set p to 11’, but with the ‘try', I get 6 matches from my desktop files.

I’d appreciate anyone (I guess I’m really asking Shane), to cast their eye over my code, and advise if it’s OK or not.

Regards

Santa

attachmentsPreparationOne error item 2 of {"file:///Users/OzSanta/Desktop/.com.apple.iLife.plist", "file:///Users/OzSanta/Desktop/.DS_Store", "file:///Users/OzSanta/Desktop/.iihour", "file:///Users/OzSanta/Desktop/.localized", "file:///Users/OzSanta/Desktop/.ResumeSwitchFlag", "file:///Users/OzSanta/Desktop/.SaveLastMidnight", "file:///Users/OzSanta/Desktop/.~lock.Monet-Giverny.pps#", "file:///Users/OzSanta/Desktop/Apple shares.numbers", "file:///Users/OzSanta/Desktop/Artificial Turf.numbers", "file:///Users/OzSanta/Desktop/attachmentsPreparationOne er.textClipping", "file:///Users/OzSanta/Desktop/Centrelink.txt", "file:///Users/OzSanta/Desktop/Compact and user-friendly Ri.textClipping", "file:///Users/OzSanta/Desktop/Debug alias", "file:///Users/OzSanta/Desktop/Engine manufacturer Briggs .textClipping", "file:///Users/OzSanta/Desktop/H310-0747.png", "file:///Users/OzSanta/Desktop/images-1.jpeg", "file:///Users/OzSanta/Desktop/images.jpeg", "file:///Users/OzSanta/Desktop/Letter.pages", "file:///Users/OzSanta/Desktop/Numbers_Chart.jpg", "file:///Users/OzSanta/Desktop/temp.pdf", "file:///Users/OzSanta/Desktop/This mower was bought in lat 2.textClipping", "file:///Users/OzSanta/Desktop/Untitled.numbers"} doesn’t understand the “getResourceValue_forKey_error_” message. number -1708

--
--  AppDelegate.applescript
--  temp
--
--  Created by Brian Christmas on 24/01/2016.
--  Copyright © 2016 MeSelf Software. All rights reserved.
--

script AppDelegate
property parent : class "NSObject"
property holdingFolder : path to desktop
property onlyPrintIndandQuarkflag : false
property ignoreGraphicConverterCount : false
property printGraphicConverterCount : 0



property runForOz : true


-- IBOutlets
property theWindow : missing value


on applicationWillFinishLaunching:aNotification
-- Insert code here to initialize your application before any files are opened 


set posixPath to POSIX path of my holdingFolder


my attachmentsPreparationOne()
end applicationWillFinishLaunching:


on attachmentsPreparationOne()
try
say "running"
set p to 1
set my ignoreGraphicConverterCount to false
set my printGraphicConverterCount to 0
set posixPath to POSIX path of (my holdingFolder)
set p to 2
set theTempList to {}
tell application "System Events"
set theItemList to every item of my holdingFolder as list
repeat with eachfile in theItemList
-- Convert input file/folder to a "System Events" alias...
try
set a to eachfile as alias
-- and determine the value of the "URL" property, which is the file URL.
set thisUrl to URL of a
-- Add the file URL to the overall result.
set end of theTempList to thisUrl
end try
end repeat
end tell
set p to 3
set holdingFolderURL to current application's NSURL's fileURLWithPath:(posixPath)
set p to 3.1
if holdingFolderURL's lastPathComponent() as string = "Links" then
set p to 4
set parentURL to holdingFolderURL's URLByDeletingLastPathComponent()
set t to {}
set p to 5
set tAll to urlsInURL_(parentURL)
set p to 6
repeat with oneURL in tAll
if oneURL's pathExtension() as text = "indd" then
set end of t to oneURL
exit repeat
end if
end repeat
if (count of t) > 0 then set theTempList to {}
end if
on error
if my runForOz then say "Prep 1. p = " & p as text
set theTempList to {}
end try
try
set p to 7
set fileManager to current application's NSFileManager's defaultManager() -- probably redundant at this stage
set my onlyPrintIndandQuarkflag to false
set p to 8
set x to 0
repeat with oneURL in theTempList -- list of URLs
set p to 9
set oneURLString to (current application's NSString's stringWithString:(oneURL))
set p to 9.1
set theExt to oneURLString's pathExtension() as text
set p to 10
if theExt = "" then -- no extension
try
set x to x + 1
say x
set p to 11
set {theFlag, theValue} to (oneURL's getResourceValue:(reference) forKey:(current application's NSURLLocalizedTypeDescriptionKey) |error|:(missing value)) -- get description
set p to 12
set theValue to theValue as text -- coerce to text
set p to 13
if theValue = "Rich Text Format (RTF)" then
tell fileManager to moveItemAtURL:(oneURL) toURL:(oneURL's URLByAppendingPathExtension:"rtf") |error|:(missing value)
else if theValue = "RTF with attachments (RTFD)" then
tell fileManager to moveItemAtURL:oneURL toURL:(oneURL's URLByAppendingPathExtension:"rtfd") |error|:(missing value)
else if theValue = "Unix Executable File" then
tell fileManager to moveItemAtURL:oneURL toURL:(oneURL's URLByAppendingPathExtension:"eps") |error|:(missing value)
else -- fall back to creator type
set attRecord to (fileManager's attributesOfItemAtPath:(oneURL's |path|()) |error|:(missing value)) as record -- returns a whole lot of stuff
set creatorType to NSFileHFSCreatorCode of attRecord -- returned as an integer; note pipes around path
if creatorType = 1.231963246E+9 then -- InDn as an integer
tell fileManager to moveItemAtURL:(oneURL) toURL:(oneURL's URLByAppendingPathExtension:"indd") |error|:(missing value)
set my onlyPrintIndandQuarkflag to true
else if creatorType = 1.481658931E+9 then -- XPR3 as an integer
tell fileManager to moveItemAtURL:(oneURL) toURL:(oneURL's URLByAppendingPathExtension:"qxp") |error|:(missing value)
set my onlyPrintIndandQuarkflag to true
end if
end if
end try
else -- it has an extension
if theExt is in {"indd", "inx", "qxp", "qxd"} then
set my onlyPrintIndandQuarkflag to true
end if
end if
end repeat
on error errmsg number errnum
if my runForOz then say "Prep 2. p = " & p as text
if errnum ≠ -1728 and my runForOz then tell application "System Events" to display dialog "attachmentsPreparationOne error " & errmsg & " number " & errnum giving up after 40
end try
#my attachmentsPrintCycleOneInstallFonts() # as alias
end attachmentsPreparationOne


on applicationShouldTerminate:sender
-- Insert code here to do any housekeeping before your application quits 
return current application's NSTerminateNow
end applicationShouldTerminate:


end script



 _______________________________________________
Do not post admin requests to the list. They will be ignored.
applescriptobjc-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >Requesting help, please (From: Brian Christmas <email@hidden>)
 >Re: Requesting help, please (From: Shane Stanley <email@hidden>)
 >Re: Requesting help, please (From: Brian Christmas <email@hidden>)
 >Re: Requesting help, please (From: Shane Stanley <email@hidden>)
 >Re: Requesting help, please (From: Brian Christmas <email@hidden>)
 >Re: Requesting help, please (From: Shane Stanley <email@hidden>)

  • Prev by Date: Re: Requesting help, please
  • Next by Date: Re: Requesting help, please
  • Previous by thread: Re: Styled Text
  • Next by thread: iBabel
  • Index(es):
    • Date
    • Thread