windows - 如何为给定文件夹中的所有文件递归切换只读状态

标签 windows file intellij-idea jetbrains-ide readonly

相关于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 上下文菜单中可用...甚至分配一些自定义快捷方式(但要小心,因为上下文(当前文件夹)在这里很重要)。


Since I haven't been able to find a solution using IntelliJ so far, I assume it's not possible.

为什么?您可以使用 IDE 功能执行相同的操作。只需选择多个文件并使用该命令:File | File Properties | Make File Read-Only (如果它们已经处于该模式,则将变为 Make File Writable;如果它们混合,将显示 Toggle Read-Only Attribute)。

这里我选择了 2 个文件( 3.php4.php )并使用 float 主菜单(否则它会覆盖文件)来显示命令:

enter image description here

关于windows - 如何为给定文件夹中的所有文件递归切换只读状态,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65790103/

相关文章:

Windows 10 x64 的 MySQL msi 安装,更改安装文件夹?

c - 当您使用 void (*)() 指针调用返回 int 的函数时会发生什么?

windows - 特殊字符导致 Windows 批处理文件关闭

intellij-idea - IntelliJ 11 - 无法删除模块? (苹果电脑)

安卓工作室 : Android Manifest doesn't exists or has incorrect root tag

maven - 如何将包含多个 jar 的外部文件夹添加到 Web 应用程序的 Maven 构建中?

c++ - 在 Qt 中错误显示 : "Fault Module Name: Qt5Cored.dll" in win 7 and when debugging : "segmentation fault" in centos linux and win 7

android - 无法打开.mp3录音java.io.FileNotFoundException

perl - perl打开文件的几种方式

java - 以文件形式访问 Java 资源