More generally useful might be this old Perl standard:
#!/usr/bin/perl -w
# rename - Larry's filename fixer
$op = shift or die "Usage: rename expr [files]\n";
chomp(@ARGV = <STDIN>) unless @ARGV;
for (@ARGV) {
$was = $_;
eval $op;
die $@ if $@;
unless ($was eq $_) {
rename($was,$_);
print $_, " " if (-f $_);
}
}
print "\n";
#-----------------------------
#% rename 's/\.orig$//' *.orig
#% rename 'tr/A-Z/a-z/ unless /^Make/' *
#% rename '$_ .= ".bad"' *.f
#% rename 'print "$_: "; s/foo/bar/ if <STDIN> =~ /^y/i' *
#% find /tmp -name '*~' -print | rename 's/^(.+)~$/.#$1/'
#-----------------------------
#% rename 'use locale; $_ = lc($_) unless /^Make/' *
#-----------------------------
When run in the same directory as a test file named like yours,
rename 's/ //g' filename*
remmoved the space but kept the file.
--
- David Fleck
On Sunday, August 16th, 2026 at 8:38 AM, David Fleck via PLUG
<[email protected]> wrote:
> Of course, my previous reply assumes you can download the file again...
>
> --
> - David Fleck
>
> On Sunday, August 16th, 2026 at 8:17 AM, Rich Shepard
> <[email protected]> wrote:
>
> > While saving a PDF downloaded from a web site I inadvertently put a space
> > between the filename and the '.pdf' suffix. Now I cannot remove that space,
> > even as root.
> >
> > filename .pdf displays as filename\ .pdf
> >
> > When I try:
> > mv filename .pdf filename.pdf
> > bash responds:
> > target 'filename.pdf' is not a directory
> >
> > Same response if I double quote "filename .pdf", and "filename\ .pdf" and
> > root gets the same results.
> >
> > A cluestick is needed to remove the space.
> >
> > TIA,
> >
> > Rich
> >
>