Why is xmove not working? Any ideas?

M

Mark Stephens

Hi,

I am attempting to use the DOS Shell command xmove to move all files from one folder to another. I t should be pretty straightforward but it isn't working and I am at a bit of a loss to know why?

Here is the sub:


Public Sub MoveFile(sSourceFile As String, sDestFile As String)

Shell "cmd /c xmove /y " & sSourceFile & " " & sDestFile

End Sub

Here are the inputs:

sSourcePath = ActiveWorkbook.Path & "\Outputs\*.*"
sDestinationPath = "C:\Users\User\Dropbox (Simulytics)\SOFTWARE\data preparation\c DASHBOARD DATABASE PRODUCTION\Inputs"

and here is the call:

Call MoveFile(sSourcePath, sDestinationPath)

Any ideas?

Kind regards, Mark
 
G

GS

Chances are your source or destination strings have spaces in them, and
so your code is missing some double quotes. You may find it easier to
use VB's FileCopy method along with the Kill statement...

FileCopy sSourceFile, sDestFile
Kill sSourceFile

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion
 
A

Auric__

Mark said:
I am attempting to use the DOS Shell command xmove to move all files
from one folder to another. I t should be pretty straightforward but it
isn't working and I am at a bit of a loss to know why?

Here is the sub:


Public Sub MoveFile(sSourceFile As String, sDestFile As String)

Shell "cmd /c xmove /y " & sSourceFile & " " & sDestFile

End Sub

Here are the inputs:

sSourcePath = ActiveWorkbook.Path & "\Outputs\*.*"
sDestinationPath = "C:\Users\User\Dropbox (Simulytics)\SOFTWARE\data
preparation\c DASHBOARD DATABASE PRODUCTION\Inputs"

and here is the call:

Call MoveFile(sSourcePath, sDestinationPath)

Any ideas?

The main problem as I see it is that "xmove" is not a standard command. (It
doesn't exist for me in Win7, 8, or 95.) Are you perhaps thinking of
"xcopy"? Or just normal "move"?

Also, as Garry pointed out, you need to "quote" the filenames. If you *need*
to do this via the shell, change the Shell line to something like this:

Shell "cmd /c xmove /y """ & sSourceFile & """ """ & sDestFile & """"

(Personally, I would do it the way Garry showed.)
 
M

Mark Stephens

Chances are your source or destination strings have spaces in them, and

so your code is missing some double quotes. You may find it easier to

use VB's FileCopy method along with the Kill statement...



FileCopy sSourceFile, sDestFile

Kill sSourceFile



--

Garry



Free usenet access at http://www.eternal-september.org

Classic VB Users Regroup!

comp.lang.basic.visual.misc

microsoft.public.vb.general.discussion

Thanks a lot Gary, worked like a dream:)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top