开发者

Powershell: Change file attributes automatically when copying

开发者 https://www.devze.com 2023-03-04 05:31 出处:网络
I have a folder of read only files. When I copy one of these files to a test l开发者_如何学运维ocation, I want to be able to copy them and not retain their original attributes.

I have a folder of read only files. When I copy one of these files to a test l开发者_如何学运维ocation, I want to be able to copy them and not retain their original attributes.

I can do this, but this is lengthy.

copy-item srcfilefullname destfilefullname
set-itemproperty destfilefullname -isreadonly $false

I did not find anything in the documentation for copy-item. I am hoping there is a shorter way.

Thanks

Steeluser


Your intention is not very clear. If you want to build a one-liner from that, try this (NOT TESTED):

copy-item srcfilefullname (set-itemproperty srcfilefullname -isreadonly $false -passthru).fullname

PassThru parameter allows Set-ItemProperty to generate and return a PSCustomObject.

0

精彩评论

暂无评论...
验证码 换一张
取 消