Groups | Search | Server Info | Keyboard shortcuts | Login | Register
Groups > perl.beginners > #19379
| Newsgroups | perl.beginners |
|---|---|
| Message-ID | <81759c5d490fe6f278dc46cdb1c4730c9cb2fa47.camel@tic.com> (permalink) |
| Subject | Re: Removing a space from file name |
| Date | 2025-02-17 13:12 -0700 |
| References | <878qq4o4j3.fsf@local.lan> |
| From | beginners@perl.org (Smoot Carl-Mitchell via beginners) |
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
smoot@tic.com
Back to perl.beginners | Previous | Next — Previous in thread | Next in thread | Find similar
Removing a space from file name hput3@fastmail.fm (hput) - 2025-02-17 12:38 -0500
Re: Removing a space from file name paul@pjcj.net - 2025-02-17 19:36 +0100
Re: Removing a space from file name beginners@perl.org (Mike Hübschen via beginners) - 2025-02-17 19:52 +0100
Re: Removing a space from file name beginners@perl.org (Smoot Carl-Mitchell via beginners) - 2025-02-17 13:12 -0700
Re: Removing a space from file name beginners@perl.org (Smoot Carl-Mitchell via beginners) - 2025-02-19 18:03 -0700
csiph-web