Inkjetart.comVisit our Foum
Tracking
My Account
Cart Contents
Checkout
   
  Home Tracking  |  My Account  |  Cart Contents  |  Checkout  
   
     
 
Quick Find
 
Advanced Search

 
Content Search
Categories
Finishing
Hardware
Ink
Media
Software/Color
Information
Newsletters
Forum
Profiles
Help & Info
Samples
Order Help
Shipping & Returns
Privacy Notice
Contact Us
Gift Voucher FAQ
Site Map
 Epson Stylus Pro 3800
Text File Split with Applescript
Recently I was doing a project that required me to make over 2000 web pages. It was for a searchable database of images and the images needed to be embedded into a web page along with keywords and captions. I'm sure there's a perl script that could have built the pages on the fly, but making real pages works better for what we need.

I decided to use the keyword database we already had to make on huge text file with every line representing a different page that needed to be made. To simplify things I used Server Side Includes so I can change the layout of the resulting pages in a snap, but I still had the problem: how to get each line into a file with the correct name. For a previous project I used a DOS program that split a text file every X lines, but I still had to go through all 600 files and name them by hand. It took the better part of a day to do and was a real pain in the wrist. This time I wanted to do it all automatically.

On the Dos/Windows side I found plenty of utilities that could split text files, but none that would take the first "word" from that file and use it for the filename. I turned to Applescript and BBEdit (because "it doesn't suck" - that's really their motto!). I'm putting up this page so that hopefully someone else who needs to do this won't have to spend 2 hours figuring out how to do it.

Script Requirements:
BBedit (I used 6.5, but I bet you could get by with the "lite" freeware version on their site
Jon's Commands (freeware, it provides the conection with the clipboard)


Here's the Script:

repeat
    tell application "BBEdit 6.5"
      activate
      select display_line 1 of text window 1
      cut selection
      make new text window
      paste
      select first word of text window 1
      cut selection
      set var1 to the clipboard
      save text window 1 to file var1
      close text window 1
    end tell
end repeat



Enjoy!
Chris Bair
 
Return to Inkjet Art Solutions home

What people are saying about us

About Our Company -- who are these guys?

Hours of Operation
Mon-Fri 8:00 am - 5:00 pm
(Mountain time - 2 hours earlier than Eastern, 1 hour later than Pacific)

Retail Store Address
2199 S. West Temple
South Salt Lake, UT 84115/td>
Sales: 800-777-2076
(US toll-free)
801-256-0360
(Utah or International)
801-256-0369 (Fax)
Contact Info / Email Us
 
 
All longevity estimates should be treated as such, Inkjet Art Solutions is not liable for pre-mature fading of prints or damage to printers through use of our products. Be sure to properly research your purchase and follow the directions given. If you need help, please contact us.
For more information regarding our policies, including our return policy, please visit our Policies Page