Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 44
  • Last Modified:

I want to use XCOPY toand have filenames with spaces.

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
fester62
Asked:
fester62
1 Solution
 
HooKooDooKuCommented:
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now