A welcome-to-PowerShell guide has the PowerShell equivalents of the commands pwd, cd, ls, find, cp, rm, mkdir, touch, cat, tail, grep, uname, mkfs, ping, man, and cut:
https://mathieubuisson.github.io/powershell-linux-bash/
In addition, one can find additional equivalences of other command-line commands, such as which, where, alias, wget, curl, type, %0, and even command overriding.
However, I am still having trouble figuring out the way to do a simple for statement in Powershell. For example, the following would group all files based on filename, assuming every filename has a .txt equivalent:
set b=0
for %a in (*.txt) do set /a b=!b!+1 > NUL & echo (!b!) & dir /b %~na.*
What is the equivalent in PowerShell? The command
ls *.txt | ForEach-Object {Split-Path -LeafBase -Path $_.Name}
lists the files. However, how do I pass the filename into the dir /b %~na.* command? It seems that as soon as I close the braces for the For-Each-Object command, then the results want to pass as an agglomeration, rather than being able to process them one line at a time. And if I add another layer around Split-Path, then the $_ ends up being a different object, so it's not able to split off the filename from the extension.
EDIT:
Is there a better way for me to parse results one at a time? The for command was suggested in the comments; I just have a hard time figuring out how to get it to process all the *.txt file; but if that were doable, maybe that would be the way to go?
The preference is to do this from command line, without needing to write to a file, if possible.