Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Rename multiple files following their directories' name

by choroba (Bishop)
on Mar 19, 2013 at 11:36 UTC ( #1024274=note: print w/replies, xml ) Need Help??


in reply to Rename multiple files following their directories' name

You can probably use a shell for this task:
for folder in folder* ; do [ -f $folder/abc.txt ] && mv $folder/abc.txt $folder/$folder.txt done

In Perl, the solution is quite similar:

for my $folder (glob 'folder*') { # or (grep -d, glob 'folder*') rename "$folder/abc.txt", "$folder/$folder.txt" if -f "$folder/abc +.txt"; }

(Untested)

لսႽ ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1024274]
help
Chatterbox?
[Corion]: Likely the date of the release of the module
[Corion]: Yep, seems like that
[Perl300]: ok, thank you Corion
[Perl300]: I was researching few modules and was not sure about what that date indicates

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (6)
As of 2017-12-11 18:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What programming language do you hate the most?




















    Results (310 votes). Check out past polls.

    Notices?