Re: Removing a space from file name

[email protected] (Smoot Carl-Mitchell via beginners)
Newsgroups perl.beginners
Message-ID <[email protected]>
On Mon, 2025-02-17 at 12:38 -0500, hput wrote:
> I have several hundred *.jpg files with this pattern
> 
> Actual example:
> 
>    'AtlantaVisitAndGrandmaHands 056.jpg'
> 
> The numbers vary, of course, but the alpha part and number of digits
> after the space is the same in all *.jpg files
> 
> I have hundreds of these all in one directory.  Not something you'd
> want to do one at a time.

Something like:

while (<*>) {
	rename $_, "$1$2.jpg" if $_ =~ /(.+) (.+)\.jpg/;
}


The RE matches any filename with a single space character and the .jpg
ending. I made the $_ explicit for clarity.
-- 
Smoot Carl-Mitchell
System/Network Architect
voice: +1 480 922-7313
cell: +1 602 421-9005
[email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.