Printing a lot of text files from folder hierarchy?

Discussion in 'Mac Basics and Help' started by Mitthrawnuruodo, May 16, 2007.

  1. Mitthrawnuruodo Moderator emeritus

    Mitthrawnuruodo

    Joined:
    Mar 10, 2004
    Location:
    Bergen, Norway
    #1
    I've got a folder containing hierarchy of a lot of files and folders. The 'ls -R > index.file' command generates a ~1650 lines file... :eek: What I would like to print out all the text files (html, css, php, js, etc), not images, pdfs, jar files, etc. with each new text file starting on a new page (most of them doesn't contain much and will probably just span 1 page anyway). Syntax colouring would be awesome, but isn't necessary, at all...

    To complicate matters I would like to print to a pdf (or any other appropriate format) because
    a) I would like to check that the correct files are chosen before starting a monster print job, and
    b) I don't want to print all this on my home printer, a nice enough inkjet photo printer, but for this I want to take it somewhere with a fast laser printer.

    I've tried setting the default printer to Adobe PDF 7.0 and used 'lpr foldername/*' command from the Terminal, which didn't go well... at all... (it made a pdf file with the name of the first subfolder and then continued to replace that file for a long while and then - when finished - deleted it).

    I'm using a demo of BBEdit as my main text editor at the moment (considering to upgrade from TextWrangler), and I even though I can do a text search through all the files I don't see an option to open and/or print all files from a folder (including subfolders).

    What do you reckon? Is there an easy way of doing this taht I'm just not seeing (or a semi-easy option, including some easy scripting and/or using Automator) or am I in for one H*** of a job?
     
  2. obrien234 macrumors regular

    Joined:
    Apr 12, 2005
    Location:
    Brighton, MI
    #2
    I'm not that knowledgeable about coding. But to filter out what you want, maybe you could use a smart folder?

    Perhaps something like:
    Rule: in "Folder"
    Rule: extension is ".txt"
    Rule: extension is ".html"
    etc....
     
  3. Mitthrawnuruodo thread starter Moderator emeritus

    Mitthrawnuruodo

    Joined:
    Mar 10, 2004
    Location:
    Bergen, Norway
    #3
    Thanks, that was actually a very good tip: Using Kind Others BBEdit text document (I've sat BBEdit as default for a lot of file types, and that covered more than just set Kind Text) on the top folder gathers all the files in the same smart folder (still a few with a bit exotic file types which).

    So far so good... :)

    Now I tried opening all in BBEdit and then using the Print All function (still with Adobe PDF as default printer, for now), and this seems to work, though the default print formatting in BBEdit seems to be really, really bad, and I have to tweak that a lot before finding a printer... :(

    Anybody know an application I can use for actually printing all those text files...?
     
  4. nplima macrumors 6502a

    Joined:
    Apr 26, 2006
    Location:
    UK
    #4
    hmmm

    no Mac available where I am right now, but here's an idea:

    recursively copy all the file types you want to a specific folder:

    cp -r *.txt /destination

    cp -r *.pdf /destination

    cp -r *.htm /destination

    ...
    then drag destination folder on printer icon.

    printer may need to be configured to "print to file" first. my computer has Windows XP with a PDF printer, so this would be easy for me right now :)

    or: use spotlight to find the files you want and drag them from there to the folder that will be printed.

    good luck.
     
  5. Mitthrawnuruodo thread starter Moderator emeritus

    Mitthrawnuruodo

    Joined:
    Mar 10, 2004
    Location:
    Bergen, Norway
    #5
    Thanks.

    But, the smooth Smart Folder solution suggested by obrien234 actually solves the gathering part very well, and without interfering with the hierarchy, too... :)

    Useng that I can, easily, open and print the files (to PDF, too).

    Now it's more of a formatting problem, getting BBEdit (or another appropriate application) to print all the files in a nice readable format. Still not entirely happy with that, even though BBEdit has been better after some tweaking.
     

Share This Page