#!/usr/bin/perl -w system "ls *.pdf > temp_pdfcrop.txt"; open(IN,"temp_pdfcrop.txt"); @FILES = ; for($i = 0; $i < @FILES; $i++) { $PDFfile = $FILES[$i]; if($PDFfile =~ /^(.*)\.pdf$/) { $command = "pdfcrop $1.pdf\n"; print $command; system $command;; $command = "mv $1-crop.pdf $1.pdf\n"; print $command; system $command; } } system "rm temp_pdfcrop.txt";