Sign in to follow this  
Followers 0
am632

xcopy isnt copying folders with spaces?

6 posts in this topic

Hi,

Im using xcopy to copy a folder to another folder, but it would seem that all files/folders with a space in the name is being missed.

Heres ma code...

RunWait(@ComSpec & ' /c xcopy /e /h /y /i "' & $SETDOCUMENTSDIR & '" "' & $TEMPFOLDER & "\Documents"  & '"', "", @SW_HIDE)

All foles/folders without spaces get copied with no problems, but anything with a space in the name gets skipped from the copy.

What am i doing wrong?

thanks

Share this post


Link to post
Share on other sites



Try this ...

; source and destination folders must exist

Local $dir1 = 'somefolder', $dir2 = 'someotherfolder'

RunWait('xcopy.exe "' & $dir1 & '" "' & $dir2 & '" /e /c /h /r /k /y /d', @SystemDir, @SW_HIDE)

Make yourself sheep and the wolves will eat you - Benjamin Franklin

Share this post


Link to post
Share on other sites

Hi thanks for the reply.

This worked very well, alot better than mine but i had to add the perameter '/d' as it was waiting in the hidden command window.

Once the copy finished tho, i compaired the original folder properties against the new 1 and there seems to be some files and a couple of folders missing but im having trouble finding out what exactly is missing and why.

do u have any ideas?

thanks again

Share this post


Link to post
Share on other sites

I have never had any troubles with the code I posted. Been using it for years.

Can you elaborate what files and folders are missing?

Also, can you post the code you tried, so we might reproduce the problem?


Make yourself sheep and the wolves will eat you - Benjamin Franklin

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Hi thanks for the reply.

This worked very well, alot better than mine but i had to add the perameter '/d' as it was waiting in the hidden command window.

Once the copy finished tho, i compaired the original folder properties against the new 1 and there seems to be some files and a couple of folders missing but im having trouble finding out what exactly is missing and why.

do u have any ideas?

thanks again

Just use Autoit..

_DirCopy("C:\Folder A","C:\Folder B")

Func _DirCopy($Source,$Destination)

    Local $Search = FileFindFirstFile($Source & "\*")
    If $Search = -1 then Return

    While 1
        $file = FileFindNextFile($Search)
        If @error then ExitLoop

        If StringInStr(FileGetAttrib($Source & "\" & $file),"D") then
            DirCreate($Destination & "\" & $file)
            _DirCopy($Source & "\" & $file, $Destination & "\" & $file)
        Else
            If FileExists($Destination & "\" & $file) then FileSetAttrib($Destination & "\" & $file,"-R")
            FileCopy($Source & "\" & $file, $Destination & "\" & $file,9)
        EndIf
    WEnd

    FileClose($Search)

EndFunc
Edited by ChrisL

Share this post


Link to post
Share on other sites

Hi.

For syncing folders, use robocopy.exe

Up to version XP026 robocopy provides exitcodes, these tell exactly what happened (or went wrong).

The versions starting with that one in robocopyGUI unfortunately do *NOT* provide exitcodes any more.

Regards, Rudi.


Earth is flat, pigs can fly, and Nuclear Power is SAFE!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0