I\'d like to batch rename files in a folder, prefixing the folder\'s name into the new names. i.e. files in C:\\house chores\\
will all be renamed house chore
Free Software 'Bulk Rename Utility' also works well (and is powerful for advanced tasks also). Download and installation takes a minute.
See screenshots and tutorial on original website.
--
I cannot provide step-by-step screenshots as the images will have to be released under Creative Commons License, and I do not own the screenshots of the software.
Disclaimer: I am not associated with the said software/company in any way. I liked the product for my own task, it serves OP's and similar requirements, thus recommending.
I know it's an old question but I learned alot from the various answers but came up with my own solution as a function. This should dynamically add the parent folder as a prefix to all files that matches a certain pattern but only if it does not have that prefix already.
function Add-DirectoryPrefix($pattern) {
# To debug, replace the Rename-Item with Select-Object
Get-ChildItem -Path .\* -Filter $pattern -Recurse |
Where-Object {$_.Name -notlike ($_.Directory.Name + '*')} |
Rename-Item -NewName {$_.Directory.Name + '-' + $_.Name}
# Select-Object -Property Directory,Name,@{Name = 'NewName'; Expression= {$_.Directory.Name + '-' + $_.Name}}
}
https://gist.github.com/kmpm/4f94e46e569ae0a4e688581231fa9e00