Jump to content

xcopy isnt copying folders with spaces?


Recommended Posts

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

Link to comment
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)

"The mediocre teacher tells. The Good teacher explains. The superior teacher demonstrates. The great teacher inspires." -William Arthur Ward

Link to comment
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

Link to comment
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?

"The mediocre teacher tells. The Good teacher explains. The superior teacher demonstrates. The great teacher inspires." -William Arthur Ward

Link to comment
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

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
Link to comment
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!

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...