[email protected] (Roger Morris) wrote:
[snip]
While functionally the same, the latest version of the perl
script is a bit cleaner. I've included it here:
---------------- cut here -------------------------------
#!/usr/bin/perl
@list = `ls _*`;
foreach $was (@list) {
chop($was); # remove newline $was =~
/^_(.+)(\.[^\.]+)$/
&& ($name = $1) && ($suf = $2); #split on last '.'
$name =~ s/_$//; # remove trailing '_', if any
$i = 1; # set instance count while (
-e $name . $mod . $suf ) { # avoid conflicts
$mod = sprintf("[%03d]", $i++);
}
rename($was, $name . $mod . $suf); # rename the file
}
---------------- cut here -------------------------------
Tom, I can't get this to work! ie seemingly it does nothing at
all - no remove "_", no rename, hence virtual printer does
overwrite any previous 'print' with same name.
Your September 2006 code works just fine. I can't find the fault
with this version.
Anyone else having success or failure with this code?
Permissions are rwxrwxrwx. Location is exactly as previous
version. launchd plist file is unchanged.
The most likely problem is that the script file has Mac end-of-line
characters (\r), rather than unix EOLs (\n). If so, you can change
them with the free TextWrangler editor or with
tr "\r" "\n" < MacFile name > UnixFile name
see 'man tr' for more details.
I had forgotten about line endings but correcting them has made no
difference. On trying to execute the script in Terminal I was getting
a "No such file or directory" until changing the @list = line to
@list = `ls /Users/rm/Desktop/cups-pdf/_*`
Now there are no error messages but no desired results either.