Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Renaming all files in a directory

by Aldebaran (Curate)
on Feb 02, 2021 at 03:17 UTC ( #11127788=perlmeditation: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    $ lsb_release -a
    No LSB modules are available.
    Distributor ID:    Ubuntu
    ...
    Release:    20.04
    Codename:    focal
    $
    
  2. or download this
     ls | perl -nle 'BEGIN {$counter=0}; $old=$_;$new="image"."$counter"."
    +.jpg";
    +rename($old,$new);$counter++;' 
    $
    
  3. or download this
    $ ls | perl -nle 'BEGIN {$counter=0}; $old=$_;$new="image"."$counter".
    +"jpg";
    > +rename($old,$new);$counter++;' 
    $ ls | perl -nle 'BEGIN {$counter=0}; $old=$_;$new="image"."$counter".
    +".jpg";
    +rename($old,$new);$counter++;' 
    $
    
  4. or download this
    $ pwd
    /home/hogan/6.scripts.personal/1.umatilla.1./template_stuff/aimages
    $ ls
    ...
    image10.jpg  image13.jpg  image1.jpg   image4.jpg  image7.jpg
    image11.jpg  image14.jpg  image2.jpg   image5.jpg  image8.jpg
    $
    
  5. or download this
    ls | perl -nle 'BEGIN {$counter=0}; $old=$_;$new="caption"."$counter".
    +".txt";
    +rename($old,$new);$counter++;'
    
  6. or download this
    $ pwd
    /home/hogan/6.scripts.personal/1.umatilla.1./template_stuff/captions
    $ ls
    ...
    caption11.txt  caption15.txt  caption4.txt  caption8.txt
    caption12.txt  caption1.txt   caption5.txt  caption9.txt
    $
    

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlmeditation [id://11127788]
Approved by GrandFather
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (5)
As of 2022-12-05 23:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?