Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

Re: File remaing and removal to a subdirectory

by jeroenes (Priest)
on Jul 11, 2001 at 16:47 UTC ( #95657=note: print w/replies, xml ) Need Help??

in reply to File renaming and removal to a subdirectory

Sure we can assist, and we even like to do so. What problems do you exactly have with the code? If you show us what you have thusfar, we can give more specific help.

Without code, I can give you pointers to docs that will probably help you on the road: perlre, rename, glob and perlop.



  • Comment on Re: File remaing and removal to a subdirectory

Replies are listed 'Best First'.
File renaming and removal to a subdirectory
by Joes (Acolyte) on Jul 11, 2001 at 16:52 UTC
    Thanks for your offer.
    At this stage I am a newby ( raw initiate) who does not know where to start, but is ploughing his way through a text and doing basic tutorial exercises.
    Any assistance would be greatly appreciated
    Joe, Townsville
      When I started with perl, I greatly enjoyed 'Learning Perl' from Randall L. Schwartz aka merlyn. Great book for the first steps in perl.

      There are two things that you need to do here. First, create a list of files you want to move around. That's done by globbing: @list = <*.puz>.

      Than you'll have to rename that file to add the 'A' and move it at the same time, the first part is done by regexes, see perlre: s/(\.puz)$/A$1/; and the second by concatenation: $name= 'subdir/' . $name.

      You'll have to rename every file, so loop over your list with for:

      for my $new ( <*.puz> ){ my $old = $new; $new =~ s/(\.puz)$/A$1/; $new = 'subdir/' . $new; rename $old, $new; }


Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://95657]
and the monks are mute...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (4)
As of 2018-05-24 02:52 GMT
Find Nodes?
    Voting Booth?