Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Copy all files from one directory to another directory

Status
Not open for further replies.

pfcbuilder

Programmer
Dec 1, 2008
2
US
Hello,

I need to compare all the files in directoryA to directoryB and if any file in directoryA is not in directoryB then I need copy those file over directoryB. Can someone please show how to do that in perl ?

Thank you very much
 
Not that I am the person that tells you what to do here, but normally people post the code they have written to try and solve their programming problem instead of asking to have it written for them.

------------------------------------------
- Kevin, perl coder unexceptional! [wiggle]
 
I am sorry but I am not asking anyone to write the codes for me. Since I am a newbie in perl I just need someone to show me how to do it. And beside I saw a lot of people here posting questions without any codes.
 
Since I am a newbie in perl I just need someone to show me how to do it.

Symantics? "Show me how to do it" sounds a lot like "do it for me".

Anyway, you can look at the module that imad77 linked you to, not that it will be installed and available for you to use, but if you can install the module you can give it a try.

You could use the File::Find module that comes with perl. Use it to traverse both directories and create a list of the files/directories in each directory and use the list to compare them. You can then use File::Copy to copy the missing files from one directory to the other.

There, I showed you how to do it but didn't write your code for you. [wink]

------------------------------------------
- Kevin, perl coder unexceptional! [wiggle]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top