#! /home/xxxx/CitrusPerl/perl/bin/perl # BatchFilePrinter.pl # Batch print text files under linux # Prints ALL of the files in the specified directory # Uses the Open Office Command Line interface # Pass a directory path as a command line argument(@ARGV) or # hard code a default directory path. # Print to a local(default(-p filename) or named(-pt printername filename)) printer # soffice -nologo -p file.txt # Print to default printer # soffice -nologo -pt namedprinter file.txt # Print to named printer # soffice -nologo -view file.txt # View a read-only version of the file # Note: The file extension clues Open Office as to the file format(I know duh!). # If no extension is present or if the file format doesn't match the "usual" # usage/definition of said extension, Open Office will pop up an # "ASCII Filter Options" dialog box to ask for the file type information. # This messes with unattended printing. So, make sure the extensions match # the document types. The print files queue faster than my Deskjet can print. # Hint and example commands from a post by Jorge Castro on Ubuntu Community Documentation. # Last Modified: May 15, 2013 by James M. Lynes, Jr. use strict; use warnings; use File::Find; use Data::Dumper; my $directory = shift @ARGV || "/home/xxxx/Guitar-Music/"; my @files; find({ wanted => \&wanted, no_chdir => 1 }, $directory); @files = sort @files; print "\n\n"; foreach my $file(@files) { print "Printing file: $file\n"; `soffice -nologo -pt Deskjet-3900-2 $directory . $file`; } sub wanted { if($_ eq '.') {return}; if($_ eq '..') {return}; push (@files, $File::Find::name); }