Powershell:复制时自动更改文件属性 [英] Powershell: Change file attributes automatically when copying
问题描述
我有一个只读文件的文件夹.当我将这些文件之一复制到测试位置时,我希望能够复制它们而不保留它们的原始属性.
我可以做到这一点,但这太冗长了.
copy-item srcfilefullname destfilefullname设置项目属性 destfilefullname -isreadonly $false
我在 copy-item 的文档中没有找到任何内容.我希望有更短的方法.
谢谢
钢铁用户
你的意图不是很清楚.如果你想从中构建一个单线,试试这个(未测试):
<前>复制项目 srcfilefullname (set-itemproperty srcfilefullname -isreadonly $false -passthru).fullnamePassThru
参数允许 Set-ItemProperty
生成并返回一个 PSCustomObject
.
I have a folder of read only files. When I copy one of these files to a test location, 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
.
这篇关于Powershell:复制时自动更改文件属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!