|
Post by xxgeek on Oct 12, 2022 18:48:14 GMT
This code gives examples to copy folders using CMD.exe (the windows command shell) Do not just copy/paste and run this code. These are examples ONLY and were written for my own setup.
Since learning to use Files, and info$() to copy an entire folder can be a daunting task, this will get the job done.
I'll be writing a function using JB code someday. Until then this will suffice.
end 'remove this when you have read and understood the following:
'Copy a folder including all files (+ system or hidden) and sub folders 'if folders on path don't exist, they get created
'Make sure you change source$ to a path that exists on your system and 'dest$ to to a folder or drive of your choice 'Do not just copy/paste and run this code.
'Here are a few examples. q$ = chr$(34) run "cmd.exe /c Xcopy ";q$;"C:\test";q$;" ";q$;"l:\test";q$;" /R /E /C /I /H /S /Q"
'or q$ = chr$(34) source$ = "c:\test" 'change your source file path here - same for the other examples
dest$ = "l:\test\test" 'change your destination file path here - same for the other examples run "cmd.exe /c Xcopy ";q$;source$;q$;" ";q$;dest$;q$;" /R /E /C /I /H /S /Q"
'or make sub
source$ = "c:\test" dest$ = "l:\test\test\test" call copyFolder source$, dest$
sub copyFolder source$, dest$ q$ = chr$(34) 'global source$, dest$ run "cmd.exe /c Xcopy ";q$;source$;q$;" ";q$;dest$;q$;" /R /E /C /I /H /S /Q" end sub
'or make a function
source$ = "c:\test" dest$ = "l:\test\test\test\test" a$ = copy$(source$, dest$)
end
function copy$(source$, dest$) q$ = chr$(34) run "cmd.exe /c Xcopy ";q$;source$;q$;" ";q$;dest$;q$;" /R /E /C /I /H /S /Q" end function
|
|
|
Post by Rod on Oct 13, 2022 7:00:20 GMT
I would suggest you put an end statement at the head of this code to stop folks copy past running unthinkingly.
|
|
|
Post by xxgeek on Oct 19, 2022 22:38:55 GMT
I would suggest you put an end statement at the head of this code to stop folks copy past running unthinkingly. Yes. Good call Rod. I'll try to remember that in future postings when it would be appropriate.
|
|