By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,903 Members | 1,081 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,903 IT Pros & Developers. It's quick & easy.

How to sent file ?!

viktorijakup
P: 10
Hello !!!

My directory D:\conv\ESSD\YJCIS\YJCIS14183\bbb.doc

I must send to X:\sgml_db\ESSD\YJCIS\YJCIS14183\
directory and rename bbb.doc to MMC1.doc.
If X:\sgml_db\...\....\YJCIS14183\ don't exist, i must create it.

"X:\sgml_db\" constant directory.

My script must choose path itself !
What I must add to this script !!!
Expand|Select|Wrap|Line Numbers
  1. use strict;
  2. use warnings;
  3. use File::Copy;
  4. use File::Path;
  5.  
  6. my $sDest = 'X:/whatever';
  7. mkpath $sDest;
  8. copy('D:/whatever/bbb.doc', qq{$sDest/MMC1.doc});
  9.  
Sep 3 '08 #1
Share this Question
Share on Google+
3 Replies


numberwhun
Expert Mod 2.5K+
P: 3,503
So, what exactly is happening when you run this? Is it doing anything that you expect? You were quite vague in the description of your issue, but I will do my best here.

Here are a couple of suggestions:

1. For the mkpath line, use the following:

Expand|Select|Wrap|Line Numbers
  1. mkpath ( $sDest, {verbose => 1} );
  2.  
This will print out to the screen telling you it created the directory. If it doesn't , then you have a problem.

2. I would modify your copy statement to be the following:

Expand|Select|Wrap|Line Numbers
  1. copy('D:/whatever/bbb.doc', qq{$sDest/MMC1.doc}) or die "Could not copy:  $!";
  2.  
That will output the error, if there is one, given during the copy step.

3. Please use code tags around any code you place in the forums. As you can see, I have done so for each example here and also corrected your original posting.

Regards,

Jeff
Sep 3 '08 #2

KevinADC
Expert 2.5K+
P: 4,059
He has this question posted on several perl forums.
Sep 3 '08 #3

viktorijakup
P: 10
Hello !!!

Thank you for correction of my script. This script runs perfectly,
but in this script i must direct path. I would like run script in all
directoties and don't rewrite path in script every time.

I have a lof of files in different directories:
Examples:
D:\conv\ESSD\YJCIS\YJCIS14136\TOC.doc;
D:\conv\ESNL\APNUM\APNUM2185\vvvv.pdf;
D:\conv\ESME\BULSCI\BULSCI2303\rrr.tex...
.........and so on....
Constant path is "D:\conv", doesn't change
%%%%
For example:
I must send from
D:\conv\ESSD\YJCIS\YJCIS14136\

selective "TOC.doc" file to

X:\sgml_db\ESSD\YJCIS\YJCIS14136\

Constant path is "X:\sgml_db", doesn't change, the same "\ESSD\YJCIS\YJCIS14136\" catalogue name.

and rename "TOC.doc" to "MMC1.doc";
if i have "vvvv.pdf" I rename "MMC1.pdf" and so on.....

My script must undestand "paths", I want sent file from
directory to the same directory, only change "D:\conv\" to "X:\sgml_db\" path.

What i must add to this script !!???
Expand|Select|Wrap|Line Numbers
  1. use strict;
  2. use warnings;
  3. use File::Copy;
  4. use File::Path;
  5.  
  6. my $sDest = 'X:/sgml_db/ESSD/YJCIS/YJCIS14136/';
  7. mkpath ($sDest, {verbose =>1});
  8. copy('D:/conv/ESSD/YJCIS/YJCIS14136/bbb.doc', qq{$sDest/MMC1.doc}) or die "Could not copy: $!";
  9.  
Thank you !

Viki
Sep 4 '08 #4

Post your reply

Sign in to post your reply or Sign up for a free account.