×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Copy a file from the list of files in a folder to another folder.

Copy a file from the list of files in a folder to another folder.

Copy a file from the list of files in a folder to another folder.

(OP)
Hi,

I have written a code for coping the Chrome 'Bookmarks' file to another folder of my system's D drive. Everything works fine but unable to copy the file. Here is the code. Please suggest me where is the problem. I am absolutely new to perl.


use strict;
use warnings;
use File::Copy;

my $src = 'C:\Documents and Settings\npds\Local Settings\Application Data\Google\Chrome\User Data\Default';
my $dst = 'D:\MyDoc\MyFab\Chrome';

opendir(DIR,"$src") or die "Cannot open : $src\n";
my @files = readdir(DIR);
closedir(DIR);

my $a = $files[4]; # This is for the file 'Bookmarks'.
copy($a,$dst) or die "Error coping file : $a\n";

Thanks in advance.
npds

RE: Copy a file from the list of files in a folder to another folder.

Which error message are you getting?

Keith
www.studiosoft.co.uk

RE: Copy a file from the list of files in a folder to another folder.

$files[4] is a very unreliable way to identify the Bookmarks file. What happens when a Chrome update creates some new directory or file in there called "Aardvark" for example? Why are you bothering to opendir and so-on... you already know what the file is called.

Your source in the copy command needs the full path.

Your destination in the copy command needs the full path including the destionation filename, not just a directory name.

Annihilannic
tgmlify - code syntax highlighting for your tek-tips posts

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close