?
Solved

How to copy files with white spaces?

Posted on 2005-04-13
3
Medium Priority
?
218 Views
Last Modified: 2012-06-27
Hi,

How do I copy files with whitespaces? I am using ActivePERL on Windows.

I tried:

$from = "white space is here.txt";
$to = "c:/";

File::Copy::syscopy($from, $to) or warn("Cannot copy\n");

File::Copy::copy($from, $to) or warn("Cannot copy\n");

Win32::CopyFile($from, $to, 1) or warn("Cannot copy " . &cwd . "/$filename!\n");

And in all of them i get the message Cannot Copy

Any suggestions?
0
Comment
Question by:newaira
3 Comments
 
LVL 69

Expert Comment

by:Callandor
ID: 13775742
Try
$from = "\"white space is here.txt\"";

The \ means quote the next character as is, and the net effect is to enclose the path in quotes.
0
 
LVL 3

Author Comment

by:newaira
ID: 13775822
Sorry, actually the second copy with File::Copy::copy does work, I just forgot to have
$to = "c:/";

instead of

$to = "c:\";

when I was testing.
0
 
LVL 48

Accepted Solution

by:
Tintin earned 1000 total points
ID: 13776891
It will work if you do:

File::Copy::syscopy $from, "$to$from" or warn "Can not copy $from $!\n";

Note that syscopy actually calls Win32::CopyFile under the covers.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

On Microsoft Windows, if  when you click or type the name of a .pl file, you get an error "is not recognized as an internal or external command, operable program or batch file", then this means you do not have the .pl file extension associated with …
Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans
Suggested Courses

621 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question