Using Powershell, I want to rename files in folders by using the name of the folder that the files are in. So in my C:\\temp directory, there are 3 folders called \'aaa\', \'bb
This will rename the files and put an underscore ('_') between the folder name and the file name:
Get-ChildItem C:\temp -Filter *.txt -Recurse | Rename-Item -NewName { $_.Directory.Name+'_'+$_.Name}