Skip to content

How to compare 2 folders using Windows PowerShell

Just copying here the Windows PowerShell script from this blog post because I really don’t want to ever lose it:

$folderA = Get-ChildItem -Recurse -path C:\folderA\
$folderB = Get-ChildItem -Recurse -path C:\folderB\
Compare-Object -ReferenceObject $folderA -DifferenceObject $folderB

I use 2 different computers to deploy a Serverless project I work on, and I noticed the deployment artifacts had different sizes depending on the computer I deployed from :s So I grabbed an archive from each deployment, unzipped them, and used this to compare them.

It turned out the culprit was Ava, which puts a bunch of js and files in node_modules/.cache/ava. Excluding the whole node_modules/.cache/** from Serverless deployment (serverless.yml > package > exclude) allowed me to shrink the deployment artifact by a few hundreds of kB. On a side note, it appears that Ava leaves behind a lot of trash in this folder, so you may want to purge it manually from time to time.

Posted in JavaScript / TypeScript / Node.js, Windows.

0 Responses

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.

Some HTML is OK

or, reply to this post via trackback.

Sorry about the CAPTCHA that requires JS. If you really don't want to enable JS and still want to comment, you can send me your comment via e-mail and I'll post it for you.

Please solve the CAPTCHA below in order to fight spamWordPress CAPTCHA