相关于how to toggle read-only for a single file in IntelliJ但不同之处在于我想知道如何一次对给定文件夹中的所有文件递归执行此操作。
由于到目前为止我还无法使用 IntelliJ 找到解决方案,因此我认为这是不可能的。因此,我的问题更具体:如何在 Windows 10 上使用 IntelliJ 终端切换文件夹中所有文件的只读状态。
最佳答案
how to toggle read-only status of all files in a folder using the terminal of IntelliJ on Windows 10.
在 Windows(至少是 FAT/NTFS)上,只需设置(或删除)只读属性即可。根据需要调整文件夹路径。
- 旧版cmd.exe(
-R
删除,+R
设置):attrib -R C:\Temp\*.*
- PowerShell 命令将如下所示:
# This affects only files in THAT folder, no folders or files in subfolders Get-ChildItem -Path "C:\Temp" -File | foreach {$_.IsReadOnly = $false} # This one will affect ALL files in that folder and all subfolders Get-ChildItem -Path "C:\Temp" -File -Recurse | foreach {$_.IsReadOnly = $false}
注释:
- 使用
$false
删除该属性和$true
进行设置。 - 可以替换
Get-ChildItem -Path
仅由dir
(将在这样的命令中工作)。
不要忘记使用File | Reload All from Disk
经过这样的外部操纵。
P.S. 此类命令可以实现为 External Tools entry因此它将在项目 View 上下文菜单中可用...甚至分配一些自定义快捷方式(但要小心,因为上下文(当前文件夹)在这里很重要)。
为什么?您可以使用 IDE 功能执行相同的操作。只需选择多个文件并使用该命令:Since I haven't been able to find a solution using IntelliJ so far, I assume it's not possible.
File | File Properties | Make File Read-Only
(如果它们已经处于该模式,则将变为 Make File Writable
;如果它们混合,将显示 Toggle Read-Only Attribute
)。
这里我选择了 2 个文件( 3.php
和 4.php
)并使用 float 主菜单(否则它会覆盖文件)来显示命令:
关于windows - 如何为给定文件夹中的所有文件递归切换只读状态,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65790103/