使用方法参考:
https://www.cnblogs.com/issacnew/p/18392262
// 作者:博客园-issacnew // 网站:https://www.cnblogs.com/issacnew/p/18392262 // 作用:qttabbar去除当前文件夹下的所有文件只读属性,使得所有文件可读var qs = new ActiveXObject("QTTabBarLib.Scripting"); var wnd = qs.activewindow; var activeTab = wnd.ActiveTab; var currentPath = activeTab.Path; var fso = new ActiveXObject("Scripting.FileSystemObject");function removeReadOnlyAttribute(folderPath) {var folder = fso.GetFolder(folderPath);var files = new Enumerator(folder.Files);// 遍历当前文件夹中的文件并去除只读属性for (; !files.atEnd(); files.moveNext()) {var file = files.item();try {var fileAttributes = file.Attributes;// 去除只读属性 (0x1 是只读属性)if (fileAttributes & 0x1) {file.Attributes = fileAttributes & ~0x1;//qs.alert("已去除只读属性: " + file.Name); }} catch (e) {qs.alert("错误: " + e.message);}}// 递归处理子文件夹var subFolders = new Enumerator(folder.Subfolders);for (; !subFolders.atEnd(); subFolders.moveNext()) {var subFolder = subFolders.item();removeReadOnlyAttribute(subFolder.Path); // 递归调用 } }// 调用函数处理当前文件夹及其子文件夹 removeReadOnlyAttribute(currentPath); qs.alert("当前文件夹及其子文件夹的所有文件已去除只读属性!");
效果如下: