Skip to content

sietsevdschoot/PsFolderDiff

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

74 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PS-FolderDiff

FolderDiff is a Powershell command line tool to compare folders contents. In order to do it quick and thoroughly, it creates a two-way hashtable of all files and their hashcode fingerprint.

Installation

Run the setup file

.\setup.ps1

Getting Started

Getting started is straight forward:

$myDocs = Get-FileHashTable "C:\MyDocuments"
$myBackups = Get-FileHashTable "C:\Backups"

$duplicates = $myDocs.GetMatchesInOther($myBackups)

$duplicates.GetFiles() | del -force

$myBackups.Refresh()
$myBackups.Save()

Operations

GetFiles

[IO.FileInfo[]] GetFiles()

Returns all files

GetFilesByHash

[IO.FileInfo[]] GetFilesByHash([IO.FileInfo] $file)

Returns all files which share the same hash as $file

AddFolder

void AddFolder([IO.DirectoryInfo] $path)

Adds all files in $path to FileHashLookup

AddFileHashTable

void AddFileHashTable([FileHashLookup] $other)

Adds all files in $other to [FileHashLookup]

Contains

bool Contains([IO.FileInfo] $file)

returns true if contains file which share the same hash as $file

GetMatchesInOther

[FileHashLookup] GetMatchesInOther([FileHashLookup] $other)

returns a new [FileHashLookup] with all files in $other which match with files in $this:[FileHashLookup]

GetDiffInOther

[FileHashLookup] GetDiffInOther([FileHashLookup] $other)

returns a new [FileHashLookup] with all files in $other which don''t match with files in $this:[FileHashLookup]

Refresh

void Refresh()

Updates all files in tracked folders:

  • Added files
  • Removed files
  • Modified files

Save

void Save([IO.FileInfo] $filename)

Saves the contents in $filename

$filename can be omitted if it was saved before.

ExcludeFilePattern

void ExcludeFilePattern(string $filePattern)

Adds a file pattern to exclude. (e.g. *.iso).

This filter is also applied on already tracked files.

ExcludeFolder

void ExcludeFolder([IO.DirectoryInfo] $folder)

Adds a directory to be excluded.

This filter is also applied on already tracked files.

Requirements

In order to run the tests, Pester 4.1.0 is required.

About

Powershell library to compare folder contents

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published