|
|
Bulk convert text files to PDF
I'm not sure what your objection to text items is. for instance, you could replace your last two subroutines with the following code:
which seems clearer and simpler to me than the whole 'length-offset' system you've used, and is likely faster (text items are very quick). You might need to tweak the list of valid extensions out if you want to use this on other file types, of course.
Bulk convert text files to PDF
Nice solution.
Oh, I have nothing against your code, only I don't like tampering with the text item delimiters (a strange form of idiosyncrasy, I hope that a cure exists). For text manipulation (and other stuff) I often make direct calls to Cocoa NSString functions. My first rewrite of your script was much more short (7 lines for the main procedure and the 3 lines of the lastPos function), but then I noticed the possibilty of errors so I added a little more control on the script, that's why I had to add the changeExtension function and more lines in the main script. Note that your changeExtension suggestion does not change the extension in every situation: if the extension is in the list you supply it will be changed, otherwise the new extension will be appended without removing the previous one. That solves cases with a file with no extension (and the consequential risk of a folder in the path containing a dot), but you have to list all possible accepted extensions for the script, and the list is really long: the convert tool can convert to PDF a lot of file types (e.g. TIFF, GIF, PSD and more graphic formats). BTW for text manipulation I often make direct calls to Cocoa functions Edited on Jun 08, '11 06:48:19AM by wallybear
Bulk convert text files to PDF
Sorry, there's no cure for that, and I'm pretty sure it's fatal. :-)
'shortness' is only one factor here clarity is also important. You identify the extension using (essentially):
I use:
If you like using cocoa commands for text manipulation, then you're stuck in XCode, though personally for any complex text manips I use the Satimage osax (which has all sorts of text goodies wrapped up in it). text items take some getting used to, but they really simplify some kinds of text operations.
with respect to your other point, you're right, but that's somewhat out of the scope of this script. all this script (unmodified) can do with images is create a pdf for each one fed to it, which isn't all that useful - if you want to create multi-image pdfs then you'd want a different script (and even then, you'd probably have more luck making pdfs straight from preview). Can't do everything...
Bulk convert text files to PDF
Too bad for the cure... :( |
SearchFrom our Sponsor...Latest Mountain Lion HintsWhat's New:HintsNo new hintsComments last 2 daysNo new commentsLinks last 2 weeksNo recent new linksWhat's New in the Forums?
Hints by TopicNews from Macworld
From Our Sponsors |
|
Copyright © 2014 IDG Consumer & SMB (Privacy Policy) Contact Us All trademarks and copyrights on this page are owned by their respective owners. |
Visit other IDG sites: |
|
|
|
Created this page in 0.06 seconds |
|