How to keep file attributes by using Copyfile in Matlab

2 ビュー (過去 30 日間)
Pedram Arabschahi
Pedram Arabschahi 2017 年 7 月 13 日
コメント済み: Guillaume 2017 年 7 月 19 日
Hello everyone,
I have a small question on how you preserve file attributes, when you use copyfile(source, destination)? By doing so, I take over the ownership, which I do not want. I just want to copy them to another folder ''Archive''.
Thank you in advance Pedram

採用された回答

Guillaume
Guillaume 2017 年 7 月 13 日
What you're seeing is the normal behaviour of file copy on all OSes.
Matlab itself does not give you any way to override that. You'll have to defer to your OS. If you're on Windows, you can use robocopy (included in windows 7, 8, and 10, not just server).
!robocopy source destination /copyall
will preserve everything.

その他の回答 (1 件)

Pedram Arabschahi
Pedram Arabschahi 2017 年 7 月 18 日
Thanks a lot. Although I take Ownership of the file. But it works. Do you know some commands, where the real owner of a file stay in the file?
Thanks. Pedram
  3 件のコメント
Pedram Arabschahi
Pedram Arabschahi 2017 年 7 月 19 日
Hi Guillaume that is what I already tried, but I do not have admin rights, that is why it did not work for me. Even with local admin rights in a network I just could run the command but still the ownership changed to "admin".
Somebody in the company explained the reason as security related to see who put the file somewhere and maybe I could go for winrar to pack & later unpack after the copy. but for many files it is a really slow approach.
Guillaume
Guillaume 2017 年 7 月 19 日
Well, yes, without administrative rights, robocopy, or any other program for that matter, will not let you impersonate another user which is required when creating a file with a different ownership than yours.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeMATLAB についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by