Board logo

標題: [技術討論] 搵軟件管理HDD/NAS嘅10TB文件 [打印本頁]

作者: CarlR696    時間: 2023-11-4 01:04     標題: 搵軟件管理HDD/NAS嘅10TB文件

提示: 作者被禁止或刪除 內容自動屏蔽
作者: bongbong3481    時間: 2023-11-4 09:56

留名學野。
作者: eo38cl    時間: 2023-11-4 14:53

本帖最後由 eo38cl 於 2023-11-4 14:54 編輯

Windows下,最好用係Whereisit,但已停止更新,最後一個版本係2014(build 220),官網已買唔到。

然後係WinCatalogEverythingabeMeda (前身CDWinder)
作者: CarlR696    時間: 2023-11-4 20:57

提示: 作者被禁止或刪除 內容自動屏蔽
作者: ericauky    時間: 2023-11-4 22:51

咁多ching,搭單問一問,有無prog 係可check hdd 內有無重複的file呢?
作者: CarlR696    時間: 2023-11-5 12:07

提示: 作者被禁止或刪除 內容自動屏蔽
作者: SuperElephant    時間: 2023-11-13 16:31

本帖最後由 SuperElephant 於 2023-11-13 19:46 編輯

回覆 5# ericauky
大型檔案比對需時, 以下答案會對比每個檔案的全部內容(hash), 而非檔案名稱

開cmd打"python --version"然後enter, 如無顯示version, 請安裝Python
新增檔案C:\dedup.py將以下代碼copy+paste落dedup.py然後save
再開cmd, 行: python "C:\dedup.py" "D:\target_directory"
"D:\target_directory" 改成你需要搵重複的路徑

代碼:
  1. import os
  2. import hashlib
  3. import argparse

  4. def calculate_sha256(file_path):
  5.     with open(file_path, 'rb') as file:
  6.         bytes = file.read()
  7.         readable_hash = hashlib.sha256(bytes).hexdigest()
  8.     return readable_hash

  9. def find_duplicates(target_directory):
  10.     file_hashes = {}
  11.     for dirpath, dirnames, filenames in os.walk(target_directory):
  12.         for filename in filenames:
  13.             file_path = os.path.join(dirpath, filename)
  14.             file_hash = calculate_sha256(file_path)
  15.             if file_hash in file_hashes:
  16.                 file_hashes[file_hash].append(file_path)
  17.             else:
  18.                 file_hashes[file_hash] = [file_path]

  19.     duplicates = {k: v for k, v in file_hashes.items() if len(v) > 1}
  20.     return duplicates

  21. # Parse command-line arguments
  22. parser = argparse.ArgumentParser(description='Find duplicate files in a directory.')
  23. parser.add_argument('directory', type=str, help='The target directory.')
  24. args = parser.parse_args()

  25. target_directory = args.directory
  26. duplicates = find_duplicates(target_directory)

  27. for hash, file_paths in duplicates.items():
  28.     print(f"Duplicate files for hash {hash}:")
  29.     for file_path in file_paths:
  30.         print(f"\t{file_path}")

  31. print(f"Scan completed. Found {len(duplicates)} duplicate hashes.")
複製代碼

作者: hoho1986    時間: 2023-11-17 09:57

WizTree
可以Export CSV,外置HDD都可以用
作者: Jip仔    時間: 2023-11-17 16:24

咁多ching,搭單問一問,有無prog 係可check hdd 內有無重複的file呢?
ericauky 發表於 2023-11-4 22:51



Duplicate Cleaner Free
https://www.duplicatecleaner.com/
作者: CarlR696    時間: 2023-11-17 17:16

提示: 作者被禁止或刪除 內容自動屏蔽
作者: CarlR696    時間: 2023-11-17 17:17

提示: 作者被禁止或刪除 內容自動屏蔽
作者: sonichkhk    時間: 2023-11-17 22:07

回覆 5# ericauky


    用fclones or ddh
作者: Jip仔    時間: 2023-11-17 23:01

根本一google 就搵到o既野,
答,
係一種侮辱。

我問的都係無咁簡單的。 ...
CarlR696 發表於 2023-11-17 17:17


請問樓主你回我喺乜嘢意思
我回5樓(搵重複的file)並非回你喎
作者: s20012797    時間: 2023-11-17 23:42

回覆  ericauky
大型檔案比對需時, 以下答案會對比每個檔案的全部內容(hash), 而非檔案名稱

開cmd打"pyth ...
SuperElephant 發表於 2023/11/13 16:31


比我我會咁寫

DupFileFind.py
  1. # This script is more robust when dealing with large files and exceptions, and presents the results in a more user-friendly way.

  2. import os
  3. import hashlib
  4. import argparse

  5. # This function is used to calculate the SHA256 hash of a file
  6. def calculate_sha256(file_path):
  7.     try:
  8.         # Create a new hashlib.sha256 object
  9.         hash_sha256 = hashlib.sha256()
  10.         # Open the file and read its content
  11.         with open(file_path, 'rb') as file:
  12.             # Read the file content in chunks and update the hash
  13.             for chunk in iter(lambda: file.read(4096), b""):
  14.                 hash_sha256.update(chunk)
  15.         # Return the hash in hexadecimal format
  16.         return hash_sha256.hexdigest()
  17.     except Exception as e:
  18.         # If an error occurs while reading the file, print the error message and return None
  19.         print(f"Error reading file {file_path}: {str(e)}")
  20.         return None

  21. # This function is used to find duplicate files in the target directory
  22. def find_duplicates(target_directory):
  23.     # Create a dictionary to store the file hashes and their corresponding file paths
  24.     file_hashes = {}
  25.     # Traverse the target directory and all its subdirectories
  26.     for dirpath, dirnames, filenames in os.walk(target_directory):
  27.         # Traverse each file
  28.         for filename in filenames:
  29.             # Get the full path of the file
  30.             file_path = os.path.join(dirpath, filename)
  31.             # Calculate the hash of the file
  32.             file_hash = calculate_sha256(file_path)
  33.             # If the file hash is already in the dictionary, add the file path to the corresponding list
  34.             # Otherwise, create a new list and add the file path to it
  35.             if file_hash:
  36.                 if file_hash in file_hashes:
  37.                     file_hashes[file_hash].append(file_path)
  38.                 else:
  39.                     file_hashes[file_hash] = [file_path]
  40.     # Select the hashes that have more than one file path from the dictionary, these are the duplicate files
  41.     duplicates = {k: v for k, v in file_hashes.items() if len(v) > 1}
  42.     return duplicates

  43. # Parse command-line arguments
  44. parser = argparse.ArgumentParser(description='Find duplicate files in a directory.')
  45. parser.add_argument('directory', type=str, help='The target directory.')
  46. args = parser.parse_args()

  47. # Get the target directory
  48. target_directory = args.directory
  49. # Find duplicate files
  50. duplicates = find_duplicates(target_directory)

  51. # Print the information of duplicate files
  52. for hash, file_paths in duplicates.items():
  53.     print(f"Duplicate files for hash {hash}:")
  54.     for file_path in file_paths:
  55.         print(f"\t{file_path}")

  56. # Print the completion message
  57. print(f"Scan completed. Found {len(duplicates)} duplicate hashes.")
複製代碼

作者: SuperElephant    時間: 2023-11-18 15:00

我哋咁多位都知道回覆既意義 亦都係抱著同一理念回po
作者: CarlR696    時間: 2023-11-18 15:43

提示: 作者被禁止或刪除 內容自動屏蔽
作者: SuperElephant    時間: 2023-11-18 16:29

回覆 16# CarlR696


宏觀d睇
我哋既興趣係觀賞一啲實力相差太遠既人
用最高姿態 最深入資訊 最詳細既回覆
反差當中相映成趣
諷刺當中帶點侮辱
明既自然明 epc垃唔垃圾亦控制唔到
回呢d po唔是淨係為咗答問題
作者: rabbit82047    時間: 2023-11-18 17:09

要問就問,要回就回,無程度高低之分

要講搵 google 就唔好問,不如搬埋 chatgpt 出黎
討論區執哂佢算數,個個都高手到唔洗問





歡迎光臨 電腦領域 HKEPC Hardware (https://h0.hkepc.com/forum/) Powered by Discuz! 7.2