I wrote a script to remove .vb code files when there are corresponding .cs files in a certain directory structure. But I felt like there were some extra statements that I had to put in there that didn't feel natural. Is there a better way to do this check and then action?
Specifically, having to do the foreach
at the end didn't seem right to me. I also didn't know if there was a more PowerShell-y way to do the change extension and test-path.
ls . -include *.vb -recurse
| ? { $cs = [System.IO.Path]::ChangeExtension($_.FullName, ".cs"); Test-Path $cs }
| % { rm $_ -force }