David Huby’s Blog Technical and business stuff

25Mar/090

Windows Powershell recursing, regular expressions, and sorting

On a project I'm currently working on, I was looking for unused JavaScript files in the scripts/ subdirectory. The easiest way to do this was by checking for references to these files in all other files in the project.

PS E:\projects\source\tickets\trunk> Get-ChildItem Website\* -recurse | Select-String -pattern "scripts\/.+js" |% { [regex]::Replace($_, ".*(scripts/.+js).*", "`$1" ); } | sort -unique

Tagged as: No Comments