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

File name with "interval"

viktorijakup
P: 10
Hi !!!

Expand|Select|Wrap|Line Numbers
  1. @rem = '--*-Perl-*--
  2. @echo off
  3. if "%OS%" == "Windows_NT" goto WinNT
  4. perl -x -S "%0" %1 %2 %3 %4 %5 %6 %7 %8 %9
  5. goto endofperl
  6. :WinNT
  7. perl -x -S %0 %*
  8. if NOT "%COMSPEC%" == "%SystemRoot%\system32\cmd.exe" goto endofperl
  9. if %errorlevel% == 9009 echo You do not have Perl in your PATH.
  10. if errorlevel 1 goto script_failed_so_exit_with_non_zero_val 2>nul
  11. goto endofperl
  12. @rem ';
  13. #!/usr/bin/perl
  14. use warnings;
  15. use strict;
  16. use File::Path;
  17. use Cwd;
  18. use File::Copy;
  19. use File::Spec::Functions;
  20. #hardcoded 
  21. my $FP = 'D:\conv';
  22. my $TP = 'X:\sgml_db';
  23. my $NAME = 'MMC1';
  24. my ($from_file, $to_file) = ($ARGV[0], $ARGV[0]);
  25. my $cwd = `cd`;
  26. chomp $cwd;
  27. my ($from_dir, $to_dir) = ($cwd, $cwd);
  28. #rename file part
  29. $to_file =~ s/.*\.(.+)/$NAME.$1/;
  30. #rename dir part
  31. $to_dir =~ s/^\Q$FP\E/$TP/;
  32. mkpath($to_dir);
  33. copy(catfile($from_dir, $from_file), catfile($to_dir, $to_file)) 
  34.     or die "can't copy file";
  35. exit 0;
  36.  
  37. __END__
  38. :endofperl
  39.  
This script work perfectly and with file name with "interval", for example: PLB2 5284.tex,
but when I run script from "Main meniu" I get mistake.

You could it view in picture:



Help me with this problem....!!!

I must have script....which send file with name with "interval" from "Main meniu".
Sep 18 '08 #1
Share this Question
Share on Google+
4 Replies


numberwhun
Expert Mod 2.5K+
P: 3,503
I would change line 33 to be:

Expand|Select|Wrap|Line Numbers
  1. copy(catfile($from_dir, $from_file), catfile($to_dir, $to_file)) or die "can't copy file: $!";
  2.  
The "$!" will print out the error that was produced from the copy attempt. Your error lets you know something was wrong, but unless you print out the actual received error, you won't know the real issue.

Regards,

Jeff
Sep 18 '08 #2

viktorijakup
P: 10
Hi !!!

Now i get mistake:

Expand|Select|Wrap|Line Numbers
  1. can't copy file: No such file or directory at D:\MMC1.bat line 21.
  2.  
V.



I would change line 33 to be:

Expand|Select|Wrap|Line Numbers
  1. copy(catfile($from_dir, $from_file), catfile($to_dir, $to_file)) or die "can't copy file: $!";
  2.  
The "$!" will print out the error that was produced from the copy attempt. Your error lets you know something was wrong, but unless you print out the actual received error, you won't know the real issue.

Regards,

Jeff
Sep 19 '08 #3

numberwhun
Expert Mod 2.5K+
P: 3,503
Hi !!!

Now i get mistake:

Expand|Select|Wrap|Line Numbers
  1. can't copy file: No such file or directory at D:\MMC1.bat line 21.
  2.  
V.

I would guess that one of the directories you are referencing in the code does not exist (or files).

Regards,

Jeff
Sep 19 '08 #4

viktorijakup
P: 10
Hi !!!

But when I call script in this manner:

Expand|Select|Wrap|Line Numbers
  1. script.bat ''file with spaces.txt''
My script work perfect...

V.



I would guess that one of the directories you are referencing in the code does not exist (or files).

Regards,

Jeff
Sep 19 '08 #5

Post your reply

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