PowerShell Script to Find Duplicate Files and Delete Them


FreeBooter

Well-known member
Pro User
VIP
Local time
1:45 AM
Posts
3,923
OS
Windows 11
Hi, everyone,

I have coded a PowerShell script that can be used for finding and deleting duplicate files on a given directory.

Powershell:
# PowerShell Script to Find Duplicate Files and Delete Them in Folder

   
    while ($true)
    {
        Write-Output ""
        $path = Read-Host "Please Enter a Directory Path to Scan"
        $path = $path -replace '"', ""
       
       
        if (Test-Path $path)
        {
            Write-Host "Valid directory path: $path"
            break
        }
        else
        {
            Write-Host "Invalid directory path, please try again."
        }
    }
   
   
    Clear-Host
   
    Write-Output "Scanning Directory: $path"
   

# Define the directory to scan
    $directoryPath = $path
   
    # Get all files in the directory
    $files = Get-ChildItem -Path $directoryPath -File
   
    # Create a hash table to store file hashes
    $fileHashes = @{ }
   
    # Variable to track if duplicates are found
    $duplicatesFound = $false
   
    # Iterate through each file in the directory
    foreach ($file in $files)
    {
        # Compute the hash of the file
        $fileHash = Get-FileHash -Path $file.FullName -Algorithm MD5
       
        # Check if the hash already exists in the hash table
        if ($fileHashes.ContainsKey($fileHash.Hash))
        {
            Write-Output ""
            # Duplicate found
            Write-Host "Duplicate found: $($file.FullName)"
            $duplicatesFound = $true
            Write-Output ""
        }
        else
        {
            # Add the hash to the hash table
            $fileHashes[$fileHash.Hash] = $file.FullName
        }
    }
   
    # Notify the user if no duplicates were found
    if (-not $duplicatesFound)
    {
        Clear-Host
        Write-Output ""
        Write-Host "No duplicates found in the ""$directoryPath"" directory."
        Write-Output ""
        Exit
       
       
    }

   
   
    # Prompt the user for confirmation
    $confirmation = Read-Host "Are you sure you want to delete the files in $path directory? (Y/N)"
   
    if ($confirmation -eq 'Y' -or $confirmation -eq 'y')
    {
        Clear-Host
        # Define the directory to search for duplicate files
        $directory = $path
       
        # Get all files in the directory and subdirectories
        $files = Get-ChildItem -Path $directory -Recurse -File
       
        # Group files by their hash value
        $duplicates = $files | Group-Object -Property { (Get-FileHash $_.FullName).Hash } | Where-Object { $_.Count -gt 1 }
       
       
        foreach ($group in $duplicates)
        {
            #define an empty array to be used as a menu
            $menu = @()
            foreach ($file in $group.Group){
                #fill the menu array with the files in this group
                $menu+=$file
            }
            #write the custom menu
            write-host "========================"
            for ($i=0;$i -lt $menu.Length; $i++){
                write-host $($i + 1) - $menu[$i]
            }
            $answer = read-host "Please use a number to select a file to keep: "

            #Check if the user supplied a valid number.  There could be some error checking here as it just checks
            #that the user supplied a number greater than 0 and less than the length + 1 because humans don't count from 0
            #It will just exit if the user submits something other than a valid number
            if (($answer -le $($menu.Length + 1)) -and ($answer -gt 0)){
                #remove the selected file from the array
                $menu[$($answer-1)] = $null
                foreach ($file in $menu){
                    #delete the files silentlycontinue because there will probably be an error from trying to delete $null
                Remove-Item -Path $menu.FullName -ErrorAction SilentlyContinue -Force
               
                }
            }

           
        }
       
       
    }

2025-01-24_17-41-52.webp

 

Attachments

My Computer

System One

  • OS
    Windows 11
    Computer type
    PC/Desktop
    Manufacturer/Model
    HP Pavilion
    CPU
    AMD Ryzen 7 5700G
    Motherboard
    Erica6
    Memory
    Micron Technology DDR4-3200 16GB
    Graphics Card(s)
    NVIDIA GeForce RTX 3060
    Sound Card
    Realtek ALC671
    Monitor(s) Displays
    Samsung SyncMaster U28E590
    Screen Resolution
    3840 x 2160
    Hard Drives
    SAMSUNG MZVLQ1T0HALB-000H1
Ah, if you find duplcates, how do you know which one to delete? Its program might not be able to find it if you delete the wrong one!
 
Last edited:

My Computers

System One System Two

  • OS
    Windows 11 Pro 24H2 26100.2894
    Computer type
    Laptop
    Manufacturer/Model
    Acer Swift SF114-34
    CPU
    Pentium Silver N6000 1.10GHz
    Memory
    4GB
    Screen Resolution
    1920 x 1080
    Hard Drives
    SSD
    Cooling
    fanless
    Internet Speed
    150 Mbps
    Browser
    Brave
    Antivirus
    Webroot Secure Anywhere
    Other Info
    System 3

    ASUS T100TA Transformer
    Processor Intel Atom Z3740 @ 1.33GHz
    Installed RAM 2.00 GB (1.89 GB usable)
    System type 32-bit operating system, x64-based processor

    Edition Windows 10 Home
    Version 22H2 build 19045.3570
  • Operating System
    Windows 11 Pro 23H2 22631.2506
    Computer type
    Laptop
    Manufacturer/Model
    HP Mini 210-1090NR PC (bought in late 2009!)
    CPU
    Atom N450 1.66GHz
    Memory
    2GB
    Browser
    Brave
    Antivirus
    Webroot
Ah, if you find duplcates, how do you know which one to delete? It's program might not be able to find it if you delete the wrong one!
Script first checks the folder for duplicates, if there is no duplicate in the given folder path it exits with No duplicates found message if there are duplicate files in given folder it lists them and ask if you want to delete them and give you option one by one to delete which files you want.
 

My Computer

System One

  • OS
    Windows 11
    Computer type
    PC/Desktop
    Manufacturer/Model
    HP Pavilion
    CPU
    AMD Ryzen 7 5700G
    Motherboard
    Erica6
    Memory
    Micron Technology DDR4-3200 16GB
    Graphics Card(s)
    NVIDIA GeForce RTX 3060
    Sound Card
    Realtek ALC671
    Monitor(s) Displays
    Samsung SyncMaster U28E590
    Screen Resolution
    3840 x 2160
    Hard Drives
    SAMSUNG MZVLQ1T0HALB-000H1
Suggestion... gather a list of all of the files with the same size first, then only hash those. If two given files are not the same size, they cannot be duplicates, and comparing sizes is much faster than generating hashes if you don't need to.

Edit: something like this...

Powershell:
Get-ChildItem -Path 'C:\Path\Goes\Here' -Filter '*.banana' -Force -Recurse -File -ErrorAction SilentlyContinue |
Group-Object -Property @('Length') | Where-Object { $_.Count -gt 1 }
 

My Computers

System One System Two

  • OS
    Windows 11 Pro 24H2
    Computer type
    PC/Desktop
    Manufacturer/Model
    Intel NUC12WSHi7
    CPU
    12th Gen Intel Core i7-1260P, 2100 MHz
    Motherboard
    NUC12WSBi7
    Memory
    64 GB
    Graphics Card(s)
    Intel Iris Xe
    Sound Card
    built-in Realtek HD audio
    Monitor(s) Displays
    Dell U3219Q
    Screen Resolution
    3840x2160 @ 60Hz
    Hard Drives
    Samsung SSD 990 PRO 1TB
    Keyboard
    CODE 104-Key Mechanical with Cherry MX Clears
    Antivirus
    Microsoft Defender
  • Operating System
    Linux Mint 21.2 (Cinnamon)
    Computer type
    PC/Desktop
    Manufacturer/Model
    Intel NUC8i5BEH
    CPU
    Intel Core i5-8259U CPU @ 2.30GHz
    Memory
    32 GB
    Graphics card(s)
    Iris Plus 655
    Keyboard
    CODE 104-Key Mechanical with Cherry MX Clears
OK, but you have to bypass execution policies before you can run unsigned scripts. Can you add the option to scan a folder and all its sub folders?
 

My Computers

System One System Two

  • OS
    Windows 11 Pro 24H2 26100.2894
    Computer type
    Laptop
    Manufacturer/Model
    Acer Swift SF114-34
    CPU
    Pentium Silver N6000 1.10GHz
    Memory
    4GB
    Screen Resolution
    1920 x 1080
    Hard Drives
    SSD
    Cooling
    fanless
    Internet Speed
    150 Mbps
    Browser
    Brave
    Antivirus
    Webroot Secure Anywhere
    Other Info
    System 3

    ASUS T100TA Transformer
    Processor Intel Atom Z3740 @ 1.33GHz
    Installed RAM 2.00 GB (1.89 GB usable)
    System type 32-bit operating system, x64-based processor

    Edition Windows 10 Home
    Version 22H2 build 19045.3570
  • Operating System
    Windows 11 Pro 23H2 22631.2506
    Computer type
    Laptop
    Manufacturer/Model
    HP Mini 210-1090NR PC (bought in late 2009!)
    CPU
    Atom N450 1.66GHz
    Memory
    2GB
    Browser
    Brave
    Antivirus
    Webroot
Script first checks the folder for duplicates, if there is no duplicate in the given folder path it exits with No duplicates found message if there are duplicate files in given folder it lists them and ask if you want to delete them and give you option one by one to delete which files you want.
Yes, but how do you know which duplicate to delete? You did not answer this.
 

My Computers

System One System Two

  • OS
    Windows 11 Pro 24H2 26100.2894
    Computer type
    Laptop
    Manufacturer/Model
    Acer Swift SF114-34
    CPU
    Pentium Silver N6000 1.10GHz
    Memory
    4GB
    Screen Resolution
    1920 x 1080
    Hard Drives
    SSD
    Cooling
    fanless
    Internet Speed
    150 Mbps
    Browser
    Brave
    Antivirus
    Webroot Secure Anywhere
    Other Info
    System 3

    ASUS T100TA Transformer
    Processor Intel Atom Z3740 @ 1.33GHz
    Installed RAM 2.00 GB (1.89 GB usable)
    System type 32-bit operating system, x64-based processor

    Edition Windows 10 Home
    Version 22H2 build 19045.3570
  • Operating System
    Windows 11 Pro 23H2 22631.2506
    Computer type
    Laptop
    Manufacturer/Model
    HP Mini 210-1090NR PC (bought in late 2009!)
    CPU
    Atom N450 1.66GHz
    Memory
    2GB
    Browser
    Brave
    Antivirus
    Webroot
Suggestion... gather a list of all of the files with the same size first, then only hash those. If two given files are not the same size, they cannot be duplicates, and comparing sizes is much faster than generating hashes if you don't need to.

Edit: something like this...

Powershell:
Get-ChildItem -Path 'C:\Path\Goes\Here' -Filter '*.banana' -Force -Recurse -File -ErrorAction SilentlyContinue |
Group-Object -Property @('Length') | Where-Object { $_.Count -gt 1 }
No need for that as all files are compared given MD5 hash algorithm getting size of all files and the hash compression will slow down the process and achieve the same result of current script.
 

My Computer

System One

  • OS
    Windows 11
    Computer type
    PC/Desktop
    Manufacturer/Model
    HP Pavilion
    CPU
    AMD Ryzen 7 5700G
    Motherboard
    Erica6
    Memory
    Micron Technology DDR4-3200 16GB
    Graphics Card(s)
    NVIDIA GeForce RTX 3060
    Sound Card
    Realtek ALC671
    Monitor(s) Displays
    Samsung SyncMaster U28E590
    Screen Resolution
    3840 x 2160
    Hard Drives
    SAMSUNG MZVLQ1T0HALB-000H1
OK, but you have to bypass execution policies before you can run unsigned scripts. Can you add the option to scan a folder and all its sub folders?
If this policy is still too restrictive, we can remove all restrictions with this command:

Set-ExecutionPolicy Unrestricted

Here is the script that scans subdirectories.

Powershell:
# PowerShell Script to Find Duplicate Files and Delete Them in Folder

    
    while ($true)
    {
        Write-Output ""
        $path = Read-Host "Please Enter a Directory Path to Scan"
        $path = $path -replace '"', ""
        
        
        if (Test-Path $path)
        {
            Write-Host "Valid directory path: $path"
            break
        }
        else
        {
            Write-Host "Invalid directory path, please try again."
        }
    }
    
    
    Clear-Host
    
    Write-Output "Scanning Directory: $path"
    

# Define the directory to scan
    $directoryPath = $path
    
    # Get all files in the directory
    $files = Get-ChildItem -Recurse -Path $directoryPath -File
    
    # Create a hash table to store file hashes
    $fileHashes = @{ }
    
    # Variable to track if duplicates are found
    $duplicatesFound = $false
    
    # Iterate through each file in the directory
    foreach ($file in $files)
    {
        # Compute the hash of the file
        $fileHash = Get-FileHash -Path $file.FullName -Algorithm MD5
        
        # Check if the hash already exists in the hash table
        if ($fileHashes.ContainsKey($fileHash.Hash))
        {
            Write-Output ""
            # Duplicate found
            Write-Host "Duplicate found: $($file.FullName)"
            $duplicatesFound = $true
            Write-Output ""
        }
        else
        {
            # Add the hash to the hash table
            $fileHashes[$fileHash.Hash] = $file.FullName
        }
    }
    
    # Notify the user if no duplicates were found
    if (-not $duplicatesFound)
    {
        Clear-Host
        Write-Output ""
        Write-Host "No duplicates found in the ""$directoryPath"" directory."
        Write-Output ""
        Exit
        
        
    }

    
    
    # Prompt the user for confirmation
    $confirmation = Read-Host "Are you sure you want to delete the files in $path directory? (Y/N)"
    
    if ($confirmation -eq 'Y' -or $confirmation -eq 'y')
    {
        Clear-Host
        # Define the directory to search for duplicate files
        $directory = $path
        
        # Get all files in the directory and subdirectories
        $files = Get-ChildItem -Path $directory -Recurse -File
        
        # Group files by their hash value
        $duplicates = $files | Group-Object -Property { (Get-FileHash $_.FullName).Hash } | Where-Object { $_.Count -gt 1 }
        
        
        foreach ($group in $duplicates)
        {
            #define an empty array to be used as a menu
            $menu = @()
            foreach ($file in $group.Group){
                #fill the menu array with the files in this group
                $menu+=$file
            }
            #write the custom menu
            write-host "========================"
            for ($i=0;$i -lt $menu.Length; $i++){
                write-host $($i + 1) - $menu[$i]
            }
            $answer = read-host "Please use a number to select a file to keep: "

            #Check if the user supplied a valid number.  There could be some error checking here as it just checks
            #that the user supplied a number greater than 0 and less than the length + 1 because humans don't count from 0
            #It will just exit if the user submits something other than a valid number
            if (($answer -le $($menu.Length + 1)) -and ($answer -gt 0)){
                #remove the selected file from the array
                $menu[$($answer-1)] = $null
                foreach ($file in $menu){
                    #delete the files silentlycontinue because there will probably be an error from trying to delete $null
                Remove-Item -Path $menu.FullName -ErrorAction SilentlyContinue -Force
                
                }
            }

            
        }
        
        
    }
 

My Computer

System One

  • OS
    Windows 11
    Computer type
    PC/Desktop
    Manufacturer/Model
    HP Pavilion
    CPU
    AMD Ryzen 7 5700G
    Motherboard
    Erica6
    Memory
    Micron Technology DDR4-3200 16GB
    Graphics Card(s)
    NVIDIA GeForce RTX 3060
    Sound Card
    Realtek ALC671
    Monitor(s) Displays
    Samsung SyncMaster U28E590
    Screen Resolution
    3840 x 2160
    Hard Drives
    SAMSUNG MZVLQ1T0HALB-000H1
Right, I understand, but like I said, it's a waste of time to hash files that cannot possibly be duplicates. If I have three files, 14 GB, 85 GB, and 2 bytes, they cannot possibly be duplicates. Hashing those bigger files is a big waste of time.
 

My Computers

System One System Two

  • OS
    Windows 11 Pro 24H2
    Computer type
    PC/Desktop
    Manufacturer/Model
    Intel NUC12WSHi7
    CPU
    12th Gen Intel Core i7-1260P, 2100 MHz
    Motherboard
    NUC12WSBi7
    Memory
    64 GB
    Graphics Card(s)
    Intel Iris Xe
    Sound Card
    built-in Realtek HD audio
    Monitor(s) Displays
    Dell U3219Q
    Screen Resolution
    3840x2160 @ 60Hz
    Hard Drives
    Samsung SSD 990 PRO 1TB
    Keyboard
    CODE 104-Key Mechanical with Cherry MX Clears
    Antivirus
    Microsoft Defender
  • Operating System
    Linux Mint 21.2 (Cinnamon)
    Computer type
    PC/Desktop
    Manufacturer/Model
    Intel NUC8i5BEH
    CPU
    Intel Core i5-8259U CPU @ 2.30GHz
    Memory
    32 GB
    Graphics card(s)
    Iris Plus 655
    Keyboard
    CODE 104-Key Mechanical with Cherry MX Clears
Yes, but how do you know which duplicate to delete? You did not answer this.
You tell me if you don't know how am i supposed to code a script that lets you know i show you the duplicates you delete the one you don't want to haven't you test the script.
 

My Computer

System One

  • OS
    Windows 11
    Computer type
    PC/Desktop
    Manufacturer/Model
    HP Pavilion
    CPU
    AMD Ryzen 7 5700G
    Motherboard
    Erica6
    Memory
    Micron Technology DDR4-3200 16GB
    Graphics Card(s)
    NVIDIA GeForce RTX 3060
    Sound Card
    Realtek ALC671
    Monitor(s) Displays
    Samsung SyncMaster U28E590
    Screen Resolution
    3840 x 2160
    Hard Drives
    SAMSUNG MZVLQ1T0HALB-000H1

My Computers

System One System Two

  • OS
    Windows 11 Pro 23H2 Build 22631.4249
    Computer type
    PC/Desktop
    Manufacturer/Model
    Sin-built
    CPU
    Intel(R) Core(TM) i7-4770K CPU @ 3.50GHz (4th Gen?)
    Motherboard
    ASUS ROG Maximus VI Formula
    Memory
    32.0 GB of I forget and the box is in storage.
    Graphics Card(s)
    Gigabyte nVidia GeForce GTX 1660 Super OC 6GB
    Sound Card
    Onboard
    Monitor(s) Displays
    4 x LG 23MP75 - 2 x 24MK430H-B - 1 x Wacom Pro 22" Tablet
    Screen Resolution
    All over the place
    Hard Drives
    Too many to list.
    OS on Samsung 1TB 870 QVO SATA
    PSU
    Silverstone 1500
    Case
    NZXT Phantom 820 Full-Tower Case
    Cooling
    Noctua NH-D15 Elite Class Dual Tower CPU Cooler / 6 x EziDIY 120mm / 2 x Corsair 140mm somethings / 1 x 140mm Thermaltake something / 2 x 200mm Corsair.
    Keyboard
    Corsair K95 / Logitech diNovo Edge Wireless
    Mouse
    Logitech G402 / G502 / Mx Masters / MX Air Cordless
    Internet Speed
    100/40Mbps
    Browser
    All sorts
    Antivirus
    Kaspersky Premium
    Other Info
    I’m on a horse.
  • Operating System
    Windows 11 Pro 23H2 Build: 22631.4249
    Computer type
    Laptop
    Manufacturer/Model
    LENOVO Yoga 7i EVO OLED 14" Touchscreen i5 12 Core 16GB/512GB
    CPU
    Intel Core 12th Gen i5-1240P Processor (1.7 - 4.4GHz)
    Memory
    16GB LPDDR5 RAM
    Graphics card(s)
    Intel Iris Xe Graphics Processor
    Sound Card
    Optimized with Dolby Atmos®
    Screen Resolution
    QHD 2880 x 1800 OLED
    Hard Drives
    M.2 512GB
    Other Info
    …still on a horse.
Right, I understand, but like I said, it's a waste of time to hash files that cannot possibly be duplicates. If I have three files, 14 GB, 85 GB, and 2 bytes, they cannot possibly be duplicates. Hashing those bigger files is a big waste of time.
If they are not duplicates, why do i need to add size of file to compression to MD5 hash algorithm which test file hashes to find out if they are identical not the size of the files.
 

My Computer

System One

  • OS
    Windows 11
    Computer type
    PC/Desktop
    Manufacturer/Model
    HP Pavilion
    CPU
    AMD Ryzen 7 5700G
    Motherboard
    Erica6
    Memory
    Micron Technology DDR4-3200 16GB
    Graphics Card(s)
    NVIDIA GeForce RTX 3060
    Sound Card
    Realtek ALC671
    Monitor(s) Displays
    Samsung SyncMaster U28E590
    Screen Resolution
    3840 x 2160
    Hard Drives
    SAMSUNG MZVLQ1T0HALB-000H1

My Computer

System One

  • OS
    Windows 11
    Computer type
    PC/Desktop
    Manufacturer/Model
    HP Pavilion
    CPU
    AMD Ryzen 7 5700G
    Motherboard
    Erica6
    Memory
    Micron Technology DDR4-3200 16GB
    Graphics Card(s)
    NVIDIA GeForce RTX 3060
    Sound Card
    Realtek ALC671
    Monitor(s) Displays
    Samsung SyncMaster U28E590
    Screen Resolution
    3840 x 2160
    Hard Drives
    SAMSUNG MZVLQ1T0HALB-000H1
Can I? Thanks!
 

My Computers

System One System Two

  • OS
    Windows 11 Pro 23H2 Build 22631.4249
    Computer type
    PC/Desktop
    Manufacturer/Model
    Sin-built
    CPU
    Intel(R) Core(TM) i7-4770K CPU @ 3.50GHz (4th Gen?)
    Motherboard
    ASUS ROG Maximus VI Formula
    Memory
    32.0 GB of I forget and the box is in storage.
    Graphics Card(s)
    Gigabyte nVidia GeForce GTX 1660 Super OC 6GB
    Sound Card
    Onboard
    Monitor(s) Displays
    4 x LG 23MP75 - 2 x 24MK430H-B - 1 x Wacom Pro 22" Tablet
    Screen Resolution
    All over the place
    Hard Drives
    Too many to list.
    OS on Samsung 1TB 870 QVO SATA
    PSU
    Silverstone 1500
    Case
    NZXT Phantom 820 Full-Tower Case
    Cooling
    Noctua NH-D15 Elite Class Dual Tower CPU Cooler / 6 x EziDIY 120mm / 2 x Corsair 140mm somethings / 1 x 140mm Thermaltake something / 2 x 200mm Corsair.
    Keyboard
    Corsair K95 / Logitech diNovo Edge Wireless
    Mouse
    Logitech G402 / G502 / Mx Masters / MX Air Cordless
    Internet Speed
    100/40Mbps
    Browser
    All sorts
    Antivirus
    Kaspersky Premium
    Other Info
    I’m on a horse.
  • Operating System
    Windows 11 Pro 23H2 Build: 22631.4249
    Computer type
    Laptop
    Manufacturer/Model
    LENOVO Yoga 7i EVO OLED 14" Touchscreen i5 12 Core 16GB/512GB
    CPU
    Intel Core 12th Gen i5-1240P Processor (1.7 - 4.4GHz)
    Memory
    16GB LPDDR5 RAM
    Graphics card(s)
    Intel Iris Xe Graphics Processor
    Sound Card
    Optimized with Dolby Atmos®
    Screen Resolution
    QHD 2880 x 1800 OLED
    Hard Drives
    M.2 512GB
    Other Info
    …still on a horse.
Also. Good job (y)
 

My Computers

System One System Two

  • OS
    Windows 11 Pro 23H2 Build 22631.4249
    Computer type
    PC/Desktop
    Manufacturer/Model
    Sin-built
    CPU
    Intel(R) Core(TM) i7-4770K CPU @ 3.50GHz (4th Gen?)
    Motherboard
    ASUS ROG Maximus VI Formula
    Memory
    32.0 GB of I forget and the box is in storage.
    Graphics Card(s)
    Gigabyte nVidia GeForce GTX 1660 Super OC 6GB
    Sound Card
    Onboard
    Monitor(s) Displays
    4 x LG 23MP75 - 2 x 24MK430H-B - 1 x Wacom Pro 22" Tablet
    Screen Resolution
    All over the place
    Hard Drives
    Too many to list.
    OS on Samsung 1TB 870 QVO SATA
    PSU
    Silverstone 1500
    Case
    NZXT Phantom 820 Full-Tower Case
    Cooling
    Noctua NH-D15 Elite Class Dual Tower CPU Cooler / 6 x EziDIY 120mm / 2 x Corsair 140mm somethings / 1 x 140mm Thermaltake something / 2 x 200mm Corsair.
    Keyboard
    Corsair K95 / Logitech diNovo Edge Wireless
    Mouse
    Logitech G402 / G502 / Mx Masters / MX Air Cordless
    Internet Speed
    100/40Mbps
    Browser
    All sorts
    Antivirus
    Kaspersky Premium
    Other Info
    I’m on a horse.
  • Operating System
    Windows 11 Pro 23H2 Build: 22631.4249
    Computer type
    Laptop
    Manufacturer/Model
    LENOVO Yoga 7i EVO OLED 14" Touchscreen i5 12 Core 16GB/512GB
    CPU
    Intel Core 12th Gen i5-1240P Processor (1.7 - 4.4GHz)
    Memory
    16GB LPDDR5 RAM
    Graphics card(s)
    Intel Iris Xe Graphics Processor
    Sound Card
    Optimized with Dolby Atmos®
    Screen Resolution
    QHD 2880 x 1800 OLED
    Hard Drives
    M.2 512GB
    Other Info
    …still on a horse.
Can I? Thanks!
We did not know that there are other software after all like me, they are coded just have GUI interface but smart as you are.
 

My Computer

System One

  • OS
    Windows 11
    Computer type
    PC/Desktop
    Manufacturer/Model
    HP Pavilion
    CPU
    AMD Ryzen 7 5700G
    Motherboard
    Erica6
    Memory
    Micron Technology DDR4-3200 16GB
    Graphics Card(s)
    NVIDIA GeForce RTX 3060
    Sound Card
    Realtek ALC671
    Monitor(s) Displays
    Samsung SyncMaster U28E590
    Screen Resolution
    3840 x 2160
    Hard Drives
    SAMSUNG MZVLQ1T0HALB-000H1
If they are not duplicates, why do i need to add size of file to compression to MD5 hash algorithm which test file hashes to find out if they are identical not the size of the files.
You don't know they're duplicates until you hash them. I'm saying you can compare the lengths of the files, and only hash them if they have the same size. If they don't have the same size, they couldn't possibly be duplicates, and you can skip the expensive hashing algorithm.

I saved your script to a file, and removed the deletion part, so it was just doing the hashing comparison.

Powershell:
ps D:\> Measure-Command -Expression { .\FreeBooter-Duplicate-Script.ps1 | Out-Null }

TotalSeconds      : 37.0816383
TotalMilliseconds : 37081.6383

Doing it my way...

Powershell:
ps D:\> Measure-Command -Expression { Get-DuplicateFile -Path 'D:\Windows ISOs' -Filter '*.*' }

TotalSeconds      : 0.2543704
TotalMilliseconds : 254.3704

Pretty significant difference.
 

My Computers

System One System Two

  • OS
    Windows 11 Pro 24H2
    Computer type
    PC/Desktop
    Manufacturer/Model
    Intel NUC12WSHi7
    CPU
    12th Gen Intel Core i7-1260P, 2100 MHz
    Motherboard
    NUC12WSBi7
    Memory
    64 GB
    Graphics Card(s)
    Intel Iris Xe
    Sound Card
    built-in Realtek HD audio
    Monitor(s) Displays
    Dell U3219Q
    Screen Resolution
    3840x2160 @ 60Hz
    Hard Drives
    Samsung SSD 990 PRO 1TB
    Keyboard
    CODE 104-Key Mechanical with Cherry MX Clears
    Antivirus
    Microsoft Defender
  • Operating System
    Linux Mint 21.2 (Cinnamon)
    Computer type
    PC/Desktop
    Manufacturer/Model
    Intel NUC8i5BEH
    CPU
    Intel Core i5-8259U CPU @ 2.30GHz
    Memory
    32 GB
    Graphics card(s)
    Iris Plus 655
    Keyboard
    CODE 104-Key Mechanical with Cherry MX Clears
You don't know they're duplicates until you hash them. I'm saying you can compare the lengths of the files, and only hash them if they have the same size. If they don't have the same size, they couldn't possibly be duplicates, and you can skip the expensive hashing algorithm.

I saved your script to a file, and removed the deletion part, so it was just doing the hashing comparison.

Powershell:
ps D:\> Measure-Command -Expression { .\FreeBooter-Duplicate-Script.ps1 | Out-Null }

TotalSeconds      : 37.0816383
TotalMilliseconds : 37081.6383

Doing it my way...

Powershell:
ps D:\> Measure-Command -Expression { Get-DuplicateFile -Path 'D:\Windows ISOs' -Filter '*.*' }

TotalSeconds      : 0.2543704
TotalMilliseconds : 254.3704

Pretty significant difference.
You're asking me to re-code all the work I have done, show me a software that does all you said this is a simple code no need to re-code it again.
 

My Computer

System One

  • OS
    Windows 11
    Computer type
    PC/Desktop
    Manufacturer/Model
    HP Pavilion
    CPU
    AMD Ryzen 7 5700G
    Motherboard
    Erica6
    Memory
    Micron Technology DDR4-3200 16GB
    Graphics Card(s)
    NVIDIA GeForce RTX 3060
    Sound Card
    Realtek ALC671
    Monitor(s) Displays
    Samsung SyncMaster U28E590
    Screen Resolution
    3840 x 2160
    Hard Drives
    SAMSUNG MZVLQ1T0HALB-000H1
Thanks FreeBooter, very useful.
Thank you for your work and for sharing.
 

My Computers

System One System Two

  • OS
    Windows 11 Pro 64-bits 24H2 26100.2894
    Computer type
    PC/Desktop
    Manufacturer/Model
    Custom self built
    CPU
    AMD Ryzen 3 3200G with Radeon Vega Graphics 3.60 GHz
    Motherboard
    MSI B350 PC MATE
    Memory
    32,00 GB TeamGroup DDR4-2667
    Graphics Card(s)
    Nvidia GeForce GT 730 & Radeon™ Vega 8 Graphics
    Sound Card
    nVIDIA GK208 HDMI/DP High Definition Audio Controller
    Monitor(s) Displays
    AOC 27"
    Screen Resolution
    3840x2160
    Hard Drives
    SSD Team Group T-Force Cardea Zero Z440 1TB Gen4 M.2 NVMe (5000/4400MB/s), SSD Team Group CX2 512GB SATA III (530/470MB/s) and 2x Seagate 1TB BarraCuda 64MB 7200rpm SATA III 3.5 - ST1000DM010
    PSU
    LC-Power 650W V2.3
    Case
    ATX Nox Hummer ZS
    Cooling
    No cooling
    Keyboard
    Logitech K220
    Mouse
    Logitech
    Internet Speed
    1000/200
    Browser
    Firefox 133.0
    Antivirus
    Windows Defender
    Other Info
    Optical Drive ASUS DRW-24D5MT
  • Operating System
    Windows 11 Pro 64-bits 24H2 26100.2894
    Computer type
    Laptop
    Manufacturer/Model
    Dell Latitude 5400
    CPU
    Intel Core i5-8365U
    Motherboard
    Dell 03WM4C - Intel Cannon Lake-U PCH-LP Premium
    Memory
    16 GB
    Graphics card(s)
    Intel UHD Graphics 620 - Whiskey Lake-U GT2
    Sound Card
    Intel Cannon Lake-LP - cAVS (Audio, Voice, Speech) [D0]
    Monitor(s) Displays
    Dell NV14N4F
    Screen Resolution
    1920 x 1080
    Hard Drives
    Micron 2200S NVMe 256 GB
    PSU
    Dell X7XY03
    Internet Speed
    1000 Mbps / 200 MBps
    Browser
    Firefox 134.0
    Antivirus
    Microsoft Windows Defender

My Computer

System One

  • OS
    Windows 11
    Computer type
    PC/Desktop
    Manufacturer/Model
    HP Pavilion
    CPU
    AMD Ryzen 7 5700G
    Motherboard
    Erica6
    Memory
    Micron Technology DDR4-3200 16GB
    Graphics Card(s)
    NVIDIA GeForce RTX 3060
    Sound Card
    Realtek ALC671
    Monitor(s) Displays
    Samsung SyncMaster U28E590
    Screen Resolution
    3840 x 2160
    Hard Drives
    SAMSUNG MZVLQ1T0HALB-000H1

Latest Support Threads

Back
Top Bottom