Solved

I want to use XCOPY toand have filenames with spaces.

Posted on 2014-10-30
2
37 Views
Last Modified: 2016-06-22
I am using VBA and a shell comand to move files from one location on the network to another, e.g.

    retval = Shell("XCOPY" & " \\MYSERVER\DATA\D1\D2\D3\Input\Historic\My File.txt ANOTHERSERVER:\TestCopy", 0)

As you can see the filename in this example has a space and the copy fails because of this. I cannot change the filenames because of other dependencies. What is the syntax to use (from with a VBA module to get this to work?


Many thanks

PS this syntax works for filenames without spaces
0
Comment
Question by:fester62
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 16

Accepted Solution

by:
HooKooDooKu earned 500 total points
ID: 40413138
Enclose the file name in quotation marks.

Perhaps something like this to get the quotation marks in there:
    retval = Shell("XCOPY " & """" & "\\MYSERVER\DATA\D1\D2\D3\Input\Historic\My File.txt ANOTHERSERVER:\TestCopy" & """", 0)
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

617 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