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

how to move the folder from one directory to another directory?

by vasuperl (Acolyte)
on Dec 28, 2014 at 03:56 UTC ( [id://1111520]=perlquestion: print w/replies, xml ) Need Help??

vasuperl has asked for the wisdom of the Perl Monks concerning the following question:

I have a folder with the name of session in the path of desktop/tma-log/loggeddata. Now I want to move the session folder into some other directory. How to move the folder into some other directory using Perl? Can any of you give some inputs how to do this?

  • Comment on how to move the folder from one directory to another directory?

Replies are listed 'Best First'.
Re: how to move the folder from one directory to another directory?
by Anonymous Monk on Dec 28, 2014 at 04:03 UTC

    The core module File::Copy has a move function.

    use File::Copy; move("/dev1/fileA","/dev2/fileB");

      thank you for your response.. But here the session folder is created dynamically along with the time stamp. Here what does file A and file B means??

        But here the session folder is created dynamically along with the time stamp. Here what does file A and file B means??

        The linked documentation says: The move function also takes two parameters: the current name and the intended name of the file to be moved

        So move( oldname, newname )

        use Path::Tiny qw/ path /; path( $oldname )->move( $newname );

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (3)
As of 2024-04-25 17:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found