Having problems printing pathlist in Leopard

Hello all!
At my workplace we recently got a few new G5's running Leopard and are having some difficulties with some scripts. This script in particular should accept a file name or multiple file names and should output the pathlist of the files to textEditor and then open up the print dialog so all the user has to do is click print. However when it runs on Leopard, it opens text edit and give an error message. It reads "Can't get last paragraph of document 1 of application 'TextEdit'. Invalid index." The source code is listed below. Any help would be greatly appreciated!
Stephen
script newfile
property pathlist : ""
property filename : ""
end script
on open (files_passed)
(* make a list that has the correct number of newfiles in it*)
set myfiles to [] as list
repeat with counter from 1 to (count of files_passed)
set myfiles to myfiles & "" as list
end repeat
repeat with counter from 1 to count of myfiles
copy newfile to item counter of myfiles
end repeat
(* set up pathlists and filenames for each of the documents*)
set pointer to 1 (*this shows which of myfiles to change*)
repeat with current in files_passed
set pathlist to the POSIX path of current
separate_path(pathlist)
set newpathlist to the result (*a list of each folder and filename in the pathlist*)
makeprintablepathlist(newpathlist)
set finished_path to the result
(*set the properties of current myfile*)
set pathlist of item pointer of myfiles to item 1 of finished_path
set filename of item pointer of myfiles to item 2 of finished_path
set pointer to pointer + 1
end repeat
sort_files(myfiles)
set myfiles_sorted to the result
(*check if textedit is open*)
tell application "System Events"
if process "textedit" exists then
set should_close to false
else
set should_close to true
end if
end tell
tell application "TextEdit"
activate
make new document at the beginning
tell document 1
set last paragraph to " "
set size of last paragraph to 10
set font of last paragraph to "Helvetica"
repeat with current in myfiles_sorted
set last paragraph to pathlist of current & " "
set font of last paragraph to "Helvetica-Bold"
set last paragraph to filename of current & " "
set font of last paragraph to "Helvetica"
set last paragraph to return & return & " "
end repeat
print
end tell
repeat while name of window 1 is "Print"
end repeat
close document 1 saving no
if should_close then
quit
end if
end tell
end open
on sort_files(currentfiles)
set sorted_files to item 1 of currentfiles as list
repeat with counter from 2 to count of currentfiles
set make_new to true
repeat with countera in sorted_files
log "filenumber:" & counter
if pathlist of item counter of currentfiles = pathlist of countera then
set filename of countera to filename of countera & ¬
filename of item counter of currentfiles
set make_new to false
end if
end repeat
if make_new then
set sorted_files to sorted_files & item counter of currentfiles as list
end if
end repeat
return sorted_files
end sort_files
on separate_path(pathlist)
set mypath to [] as list
set nextword to ""
repeat with pointer from 2 to (count of characters of pathlist)
if character pointer of pathlist is not equal to "/" then
set nextword to nextword & character pointer of pathlist
else
set mypath to mypath & [nextword]
set nextword to ""
end if
end repeat
set mypath to mypath & [nextword]
set nextword to ""
return mypath (*a list of each folder and filename in the pathlist*)
end separate_path
on makeprintablepathlist(mypath)
set pathlist to ""
set tabs to tab & tab & tab & tab & tab & tab & tab & tab & tab
repeat with counter from 1 to ((count of mypath) - 1)
set pathlist to pathlist & tabs & item counter of mypath & return
end repeat
set filename to tabs & " " & the last item of mypath & return
return [pathlist, filename]
end makeprintablepathlist

Hi sevans4262 and welcome to Apple Discussions!
It's because when you first create the TextEdit document, it doesn't have any paragraphs, so there can't be a "last paragraph", so it can't count it.
Even if there was a paragraph Your script as it stands would also replace the last paragraph with your new text every time you loop.
There are downloadable illustrations of how to manipulate TextEdit documents here. The syntax is basically
tell application "textedit"
tell front document to set text to "Something"
end tell
But...
TextEdit is not particularly rewarding to script The simplest approach I can see that would work would be to concatenate the entire text, drop it into the TextEdit document in one go, and then loop through the paragraphs setting the font and size.
You'll have a much more fruitful experience if you experiment with a freeware text editor like TextWrangler or a shareware product like Tex-Edit Plus. Both have far richer and more manageable scripting abilities than TextEdit, and Tex-Edit Plus in particular is very well documented. IMHO.
H
H

Similar Messages

  • Having problem printing to hp officejet pro 8500 since updated to yosemite. any help please?

    I am having problem printing to Hp Officejet pro 8500 printer, it says it is in use. I never had any problem until Yosemite update. Any ideas please?

    I had the same problem with a HP 4000 laser jet & SL, this is how I solved it
    http://www.macworld.com/article/142631/2009/09/snowleopard_printing.html

  • Sorry for my ignorance but i'm having problems printing

    Hi
    I am very new to indesign and to print graphics.  I am not new to web graphics.
    I am having problems printing a document that I have created in InDesign CS5.  Now I have learnt that I need to calibrate stuff with ICC profiles but I am not sure what I am doing.
    Do i need to create aan ICC profile for my monitor and printer?
    How do I get these to worl with InDesign?
    I suppose I need to tell you what is going on.   When I print my document which is mostly different shades of grey, most of the different grey shades are nearly black and I can only just see the differentces in shades between the grays.  Now on my monitor they are distinctly different and can easily be seen.
    So what steps do I nee dto get these colours right?
    Cheers

    For good reproduction you need an accurate monitor profile (this is done with a colorimeter or spectrophotometer --that's overkill for just the monitor, but it can do the printer, too -- and profiling software) and an output profile for the printer and paper combination. The industry standard EyeOne colorimeter package is around $200, the spectrophotometer will cost quite a bit more.
    There are services that will profile your printer for you, too, but learing to do it yourself will cost less over the long haul if you are really serious about the output quality. In theory you need to recalibrate and profile printers on a regular basis, especially when you change ink or toner. Out here in the real world, though, I suspect most of us who are not producing commercial color output just do it once and live with it until the results are no longer acceptable and the profiles need to be updated. I proof for internal use on my color laser, for example, and it hasn't been re-profiled for about three years. It no longer matches waht I see on the monitor exactly, but it's still fairly close and the prints are for my own use. I always get a proof from the printer when it's time to go to press.
    Of course not all monitors and not all printers are created equal. Some monitors are incapable of showing fine gradtions in sahding in the dark or very light grays, and many, if not most, printers can't capture all of the shades you can see on screen.
    For any given printer resolution, such as a 600 dpi printer, the higher the linescreen value used to print, the lower the number of shades that can actually be produced. Halftone spots (which is what are used to fool you into seeing gray using only black ink) are made up of groups of printer dots, and you can't print half a printer dot, so, for example, 600 dpi printer outputting at 100 lines per inch linescreen, uses about 36 printer dots to make each halftone spot (it might be a little different because the shape of the halftone spot is seldom a square). The best you can get from 36 printer dots is 37 levels (no dots to all dots), so the best you can hope for is about 3% steps.
    Add in dot gain, the spread of ink or toner as it's absorbed into the paper and which is more prominent at darker shades, and your shadows tend to plug up, and the very light shades may not show at all. Less than 5% dot, for example is extremely hard to print on most lasers.
    A really good book on the subject is Real World Scanning and Halftones, and a great book on color management in general is Real World Color Management.

  • I'm having problems printing from my 15" macbook pro to my HP wireless printer. It works sometimes but not reliably, it can spend hours "seating for printer". I can print from my i pad with no problems

    I'm having problems printing from my 15" macbook pro to my HP wireless printer. It works sometimes but not reliably, it can spend hours "seating for printer". I can print from my i pad with no problems

    Hi,
    Apple's AirPrint only support specific models while using wired or wireless network connection.
    Plugging a printer into a USB port of Apple base is not supported for AirPrint:
    AirPrint printers connected to the USB port of the Apple AirPort Base Station or Time Capsules are not supported with AirPrint.
    As well you must use AirPrint enabled printers for a such, none of your printers are AirPrint enabled:
    http://support.apple.com/kb/ht4356
    There are 3rd party solutions which allow sharing a printer connected to your Mac as AirPrint, Printopia as example provide a such:
    http://www.ecamm.com/mac/printopia/

  • I am having problems printing a Keynote file to a Keyocera c3232

    I am having problems printing a Keynote file to a Keyocera c3232. 
    Its a 100MB file sent from a Mac Pro 2 x 2.4 GHz Quad Core to a the C3232 which has 768MB of memory installed. 
    I have even optizmized the PDF down to 30 mb and still taking about a 40 mins.  Just got a "Unable to send Trailing nul to printer. Broken Pipe"
    any ideas folks. I can run the same files to a big production machine and it takes 5 mins to print at the most.
    help!

    same thing at 10.7.3!
    brilliant paing with iphone and ipad
    otherwise no sound with imac

  • Anyone having problems printing with aps?

    Any one having problems printing while using an ap?

    you need the drivers...
    win 7 32 bit:
    http://h20000.www2.hp.com/bizsupport/TechSupport/SoftwareIndex.jsp?lang=en&cc=us&prodNameId=439154&p...
    win 7 64 bit:
    http://h20000.www2.hp.com/bizsupport/TechSupport/SoftwareIndex.jsp?lang=en&cc=us&prodNameId=439154&p...
    Although I am working on behalf of HP, I am speaking for myself and not for HP.
    Love Kudos! If you feel my post has helped you please click the White Kudos! Star just below my name : )
    If you feel my answer has fixed your problem please click 'Mark As Solution' and make it easier for others to find help quickly : )
    Happy Troubleshooting : )

  • HT2506 Is there anyone else who is having problems printing with Preview since upgrading to Lion OS X?

    Since upgrading to Lion OS X, I have not been able to print any of my documents that were created in Adobe PDF.  All calls to customer support have been a bust.
    When I try to print anything it comes out looking like this:
    Apple PREVIEW team!!!!  PLEASE HELP!!!

    Hi Linc...
    Here is a copy of your prior post to me on a different forum...
    Still no resolution...
    Linc Davis
    Re: Anyone having problems with Preview since upgrading to Lion OS X?  When using a pdf form that allows multiline text, I am finding that the printing is completely illegible.  The lines are stacking on top of each other. 
    Mar 11, 2012 3:13 PM (in response to pshrynking)
    Please read this whole message before doing anything.
    This procedure is a test, not a solution. Don’t be disappointed when you find that nothing has changed after you complete it.
    Step 1
    The purpose of this step is to determine whether the problem is localized to your user account.
    Enable guest logins and log in as Guest. For instructions, launch the System Preferences application, selectHelp from the menu bar, and enter “Set up a guest account” (without the quotes) in the search box.
    While logged in as Guest, you won’t have access to any of your personal files or settings. Applications will behave as if you were running them for the first time. Don’t be alarmed by this; it’s normal. If you need any passwords or other personal data in order to complete the test, memorize, print, or write them down before you begin.
    Test while logged in as Guest. Same problem(s)?
    After testing, log out of the guest account and, in your own account, disable it if you wish. Any files you created in the guest account will be deleted automatically when you log out of it.
    Note: If you’ve activated FileVault in Mac OS X 10.7 or later, then you can’t enable the Guest account. Create a new account in which to test, and delete it, including its home folder, after testing.
    Step 2
    The purpose of this step is to determine whether the problem is caused by third-party system modifications that load automatically at startup or login.
    Disconnect all wired peripherals except those needed for the test, and remove all aftermarket expansion cards. Boot in safe mode and log in to the account with the problem. The instructions provided by Apple are as follows:
    Be sure your Mac is shut down.
    Press the power button.
    Immediately after you hear the startup tone, hold the Shift key. The Shift key should be held as soon as possible after the startup tone, but not before the tone.
    Release the Shift key when you see the gray Apple icon and the progress indicator (looks like a spinning gear).
    Safe mode is much slower to boot and run than normal, and some things won’t work at all, including wireless networking on certain Macs.
    The login screen appears even if you usually log in automatically. You must know your login password in order to log in. If you’ve forgotten the password, you will need to reset it before you begin.
    Test while in safe mode. Same problem(s)?
    After testing, reboot as usual (i.e., not in safe mode.) Post the results of steps 1 and 2.
    pshrynking
    Re: Anyone having problems with Preview since upgrading to Lion OS X?  When using a pdf form that allows multiline text, I am finding that the printing is completely illegible.  The lines are stacking on top of each other. 
    Mar 11, 2012 4:13 PM (in response to Linc Davis)
    Did all of that yesterday, with the Apple Representative on the phone, and nope, still a problem...it was kind of exciting, really, they kept going up and up the tiers of support until I got disconnected...Fortunately I had the email address of the gentleman who was helping me so that I could email him back and let him know that we got disconnected...as you might imagine, he still has not emailed me back.  They were able to receive a copy of the form that I use for charting and try it in their facility on their computers, so we know:
    1- it is not just my computer.
    2- it occurred only after installing Lion OS X, not sure if they have tried it on Snow Leopard, but that's what I would have done if I was them...assuming that somewhere in Apple someone has not upgraded to Lion.
    3- it is not just my software.
    I think the problem is with the newer iteration of Preview  not communicating well with the Adobe .pdf.  probably some line of coding that needs to be written and insertedinto their program for multiline text.
    :-)  Thank you for your help!

  • Having problems printing using ePrint from email with an SMTP transmission failure

    I am having a problem printing from my Apple devices (iPhone, iPad (both running iOS 5), Mac Book Pro and iMac (Lion)) from my Mobile me account (Apple's @me.com mail). My printer is a D110a and is up-to-date. The return error message I'm getting is attached. The printer is working fine as a wireless printer but whenever I try to email something to the ePrint printer address (@hpeprint) I get this message. While I wasn't a heavy user of emailing to this printer, I did have it working. I'm very discouraged by all of the postings I've found on very similar if not identical problems that others are having ... Please help! Your message cannot be delivered to the following recipients:  Recipient address: [email protected]  Reason: SMTP transmission failure has occurred  Diagnostic code: smtp;550 5.7.1 Command rejected  Remote system: dns;email.hpeprint.com (TCP|17.148.16.96|51538|15.201.224.75|25) (hpeprint.com ESMTP Postfix) Original-envelope-id: [email protected] Reporting-MTA: dns;asmtp021-bge351000.mac.com (tcp-daemon) Arrival-date: Tue, 13 Dec 2011 15:27:06 +0000 (GMT) Original-recipient: rfc822;[email protected] Final-recipient: rfc822;[email protected] Action: failed Status: 5.7.1 (SMTP transmission failure has occurred) Remote-MTA: dns;email.hpeprint.com (TCP|17.148.16.96|51538|15.201.224.75|25) (hpeprint.com ESMTP Postfix) Diagnostic-code: smtp;550 5.7.1 Command rejected initions=main-1112130128

    I cannot say if this is a supported path or not, but I have a few thoughts about what you are doing. I have done a few prototypes that would send emails programatically to eprint printers.
    1. do you recieve the email if you send it to a different address (your email address) - you said the email is making it out of the server, but does it make it to destinations.
    2. can you try this with your own printer that has an hp connected account? this would make it easier to troubleshoot.
    3. hpconnected has the idea of open to anyone or allowed senders only. depending on how your customer has their printer setup, you could be blocked by the service because of those settings. with those options, they also have the option to block users or allow users to either of those settings.
    3a. login to hpconnected.com, select devices, look at the device being printed to, and there is a column for ePrint Access that will say 'Allowed Senders Only' or 'Open to Anyone'. going to the settings for a printer will give more details about these settings, and allow you to manage blocked / allowed users.
    More info under 'Manage ePrint Preferences' on this doc:
    http://h10025.www1.hp.com/ewfrf/wc/document?docname=c03550522&cc=us&dlc=en&lc=en
    4. I believe that in hpconnected, you can look at collections and it will show all recieved jobs - which would allow them to be printed again. I think this will list received jobs from email.
    I work for HP.
    David

  • I am having problems printing with my HP 800PS design jet.

    I am have problems printing with my HP 800PS design jet. I have to call IT all the time and it is losing its print settings and the print screen will freeze uot all the time. I am told that HP does not support this product any more.

    This forum is focused on consumer level products.  For the Designjet you may have better results posting in the HP Designjet forum here.
    Bob Headrick,  HP Expert
    I am not an employee of HP, I am a volunteer posting here on my own time.
    If your problem is solved please click the "Accept as Solution" button ------------V
    If my answer was helpful please click the "Thumbs Up" to say "Thank You"--V

  • For those of you having problems printing images/pdf

    I spent awhile figuring this out as my Samsung ML-1630 printed text from TextEdit fine via Time Capsule USB, but I kept getting either errors or nothing at all when I attempted to print a PDF, web page, or image. Here is how I got it to work (I have only tested it on a Samsung ML-160 printer, but it should work for others having similar problems)
    1. Open "Print & Fax" in System Prefs
    2. Add a new printer.
    3. (important!) Choose IP at the top.
    4. For "Protocol" choose "HP Jetdirect - Socket"
    5. For "Address" use the local IP address of your Time Capsule - you can find this by opening the AirPort Utility -- mine was 10.0.1.1 by default.
    6. For "Print Using" select your printer driver
    7. Click "Add" and you should be able to print anything now
    This workaround is probably due to a driver issue, but I am not for certain.

    Thanks,
    This worked for printing images, but it is PAINFULLY slow. took 3 minutes or more to print a simple graphic file
    Message was edited by: AceMT

  • Help! I am having problems printing to HP LaserJet P1006? How can I get it to work?

    Hey All! I have an old iMac that I am having a few issues with getting it to print with my HP LaserJet P1006. It will print from MS Word, but not any other program. Whenever I try to print from any other program (Excel, Preview, Firefox browser) it says that the print job has been stopped, and if I try to restart it  or resend it to the printer, it simply stops it again and I have no idea why. I have already tried all of the basics (restarting my computer, reinstalling the driver, unplugging and restarting the printer, etc) and am at a loss. Does anyone have any suggestions?

    Might try these two...
    Mac OS X: About the Reset Printing System feature ...
    http://support.apple.com/kb/HT1341?viewlocale=en_US
    Might try Printer Setup Repair 5.1...
    http://www.fixamac.net/software/index.html

  • Printers having problems printing PAGES 8 -  HP and Cannon

    I am trying to print a tri-fold church bulletin using the duplex option. My HP (7410 All in one) cuts off a half inch of the trailing edge on both sides. So I decided to use my Cannon (iP6700D)- the same document has been spooling for 20 minutes. Is Pages 8 a finished product - it looks great on the screen. Both printers are wireless. I never had a problem with version 6 that I remember. Any help is appreciated.

    the trailing edge problem is inherent to the printer and the driver. If you have a borderless option for your printer, try using that.
    As for the Canon problem, again that is going to be a printer driver issue.
    My suggestion would be to save the file as a PDF and then try printing the PDF. This removes Pages from the equation for testing purposes.
    (If these problems never showed up in iWork '06, then it may have been a global variable you had set in that program or driver. Once you set the printer you can view the layout and see how the unprintable areas will work. Avoid anything that is in the grey border and your printout should be fine.
    )

  • Why am I having problems printing with Photoshop CS6?

    My problems started when I upgraded to Adobe CS6. Colors are off, and prints are dull, almost murky. I thought it was the printer at first, so I swapped out all my ink (big mistake), cleaned the print heads (another mistake). None of these measures were necessary. I adjusted my CS6 color settings based on advice from sources like Linda.com. No improvement. Finally I saved my Photoshop file as a flat Tiff and printed from Mac Preview. The print was gorgeous! CS6 is the problem, I just don't know how to fix it. I'd hate to have to use Preview everytime I want to print from Photoshop. The printer is fine, the paper is fine, changing RGB settings doesn't help. Any ideas?
    Later that same day:
    I think I figured out a simple solution. When I selected the printing option to allow the printer to control color, rather than Photoshop, my print came out better. I've been reading threads all over the tubes and no one suggested that

    Yes you solved your own question, use printer handles color, whcih shodul have been the default. If you do want to experiment with Photohsop manages color, try the CMYK profiles, and send a cmyk file. Only exception is if you print to one of the few RGB printers like a lambda.

  • I am having problems printing from my iPad via my AirPort Extreme network.

    I am having no success printing from my iPad via my AirPort Extreme based local network. I can use this to print wirelessly from my iMac OS X 10.7.5 and MacBook Pro OS X 10.6.8. I have 2 printer options: HP Laserjet (B&W) P1005 hard-wired to the iMac and HP Photosmart 7760 hard-wired to the AirPort Extreme. I believe I have checked all the correct boxes to enable the network and the iPad to connect, including ensuring that it is using the same network but when I try to select a printer I get the message that no printer can be found. Will it not work with an AirPort Extreme based network or only if this is connecting to wirelessly enabled printers which I do not have.
    Thanks for any suggestions.

    Hi,
    Apple's AirPrint only support specific models while using wired or wireless network connection.
    Plugging a printer into a USB port of Apple base is not supported for AirPrint:
    AirPrint printers connected to the USB port of the Apple AirPort Base Station or Time Capsules are not supported with AirPrint.
    As well you must use AirPrint enabled printers for a such, none of your printers are AirPrint enabled:
    http://support.apple.com/kb/ht4356
    There are 3rd party solutions which allow sharing a printer connected to your Mac as AirPrint, Printopia as example provide a such:
    http://www.ecamm.com/mac/printopia/

  • Having problem printing to HP Laserjet 4200 with SL

    Please help:( I am unable to print to my hp laserjet 4200. I noticed the problem after installing SL. I receive the message "unable to connect to printer". Any suggestions? Bear with me, I am not an IT wizard.
    Thanks!

    I had the same problem with a HP 4000 laser jet & SL, this is how I solved it
    http://www.macworld.com/article/142631/2009/09/snowleopard_printing.html

Maybe you are looking for

  • Late 2011 Macbook Pro Freezing ......

    My Macbook Pro keeps freezing and it is driving me crazy. It typically freezes about 3 times a week. I usually have my Macbook Pro attached to a 23" Cinema Display (With Macbook Pro screen closed), 2 daisy chained external WD mybook external drives (

  • Flash Builder flash pro project doesnt show code hintings for library assets exported for AS ?

    Flash Builder flash pro project doesnt show code hintings for library classes exported for AS ? So is there any way I can fix this ? Only way I could think of is export a swc from the fla... is there a more convenient way to do this ?

  • Summing Some Rows

    How do I Sum some records? I have a report which shows data something like this: Customer  Job_No  Vendor  Vendor_Cost  Sale_Amt 12345678  123456  ABCDEF  10.50        123.45 12345678  123456  UVWXYZ  20.92        123.45 87654321  123456  LMNOPQ  12.

  • Not able to transfer Integration Process in ID. Also not seen in SXI_Cache

    Hi Experts, I am trying a BPM scenario. I have created all design objects along with Integration Process in IR and saved and activated the same. Issue is : I am not able to transfer the Integration Scenario from IR in ID. I am also not able to see th

  • Not enough Memory, .3ds 3D Layer

    Excuse my english System Spec: PC 1 Phenom 2 (4x4 GHZ) RAM 8GB 1333 Geforce GTX 275 1024MB Scratch Disk - 40GB Raptor High Speed Disk unfragmented PC2 Phenom 2 (4x3,2 GHZ) RAM 4GB 1333 AMD Radeon 6870 Scratch Disk - 100GB unfragmented Its nearly not