czkawka icon indicating copy to clipboard operation
czkawka copied to clipboard

Permission error deleting files using GUI on Windows 10

Open milkandrelish opened this issue 2 years ago • 4 comments

Hello, I just started using Czkawka. While the search for duplicates feature works well, I am unable to delete the files, as I get the following error:

'Failed to delete file [File Path Name], reason Access is denied. (os error 5)'

I have tried running the GUI as an administrator, but this hasn't yielded results. Does anyone know why this might be happening / a potential fix?

milkandrelish avatar Sep 09 '22 21:09 milkandrelish

I can confirm this issue on Windows 11.

dvnoble avatar Sep 20 '22 17:09 dvnoble

i have the same issue

KeenMaron avatar Sep 22 '22 11:09 KeenMaron

This maybe not czkawka's fault, I found that the files I copied from other device have been set "read only" attribution automatically. The "read only" file can be deleted by explorer.exe only, but not other script or programs.

  1. check out whether your account have the permission to modify the files
  2. check out whether the file has "read only" attribution

Maybe the Windows system tools icacls.exe and attrib.exe are useful.

zombie110year avatar Nov 19 '22 16:11 zombie110year

I have python code to change the premission into absolute control. Then you can delete the files in your path.

from pathlib import Path
import os

def set_full_control_permissions(path):
    path = Path(path)

    # 遍历路径下所有文件
    for file_path in path.glob('**/*'):
        # 仅处理文件,不处理文件夹
        if file_path.is_file():
            # 获取文件的绝对路径
            absolute_path = file_path.resolve()

            # 获取文件的属性
            file_attributes = os.stat(absolute_path)

            # 将文件的属性设置为 read-write/executable
            os.chmod(absolute_path, file_attributes.st_mode | 0o777)

# 使用示例
set_full_control_permissions('D:\\documents\\Wechat\\WeChat Files')

RebelYoung avatar Jan 26 '24 01:01 RebelYoung