Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

How to? Copy DIRs with attributes ...

Jan
652
15
I have the following scenario:

dir-structure1.png


As you can see, the Directories have attributes too.

I have no problem to copy the whole structure with external xcopy or robocopy ...

Code:
xcopy d:\_Tests\Test-DIR-Structure-for-BAK-CHK v:\_Temp\test /e /h /k

robocopy d:\_Tests\Test-DIR-Structure-for-BAK-CHK v:\_Temp\test /e

The result in target is the same as in source.

BUT I HAVE a problem to make this with the internal copy command! I tried ...

Code:
copy /h /k /s d:\_Tests\Test-DIR-Structure-for-BAK-CHK v:\_Temp\test

Then the result is this ...

dir-structure2.png


How can I preserve the directory attributes with the internal copy command?

Greetings!
 
COPY doesn't do that, as you've already shown. I think you would have to do it as two steps: copy the directory structure first, then go back and copy the attributes. Possibly by redirecting the output of ATTRIB /A:D /S to a file, then using SED or the like to massage that file into a batch file?
 
All right, thank you!

It's not a MUST to use the internal copy for such processes - I was just not completely sure if it's "direct" possible anyway.

However: I know now that I would have to use a workaround as you suggested above.
 
There's also COPYDIR. It also doesn't copy attributes. I was a little surprised to find that Explorer does copy the attributes of directories (copy/paste, drag/drop). I wonder whether that's the default for SHFileOperation and how easily Rex could add it to COPYDIR (don't know if COPYDIR uses SHFileOperation). You could make a suggestion out of it.
 

Similar threads

Replies
7
Views
2K
Back
Top