Open the windows menu.
Type: "PowerShell" and open the 'Windows PowerShell' command window.
Goto folder with desired files: e.g. cd "C:\house chores"
Notice: address must incorporate quotes "" if there are spaces involved.
You can use 'dir' to see all the files in the folder. Using '|' will pipeline the output of 'dir' for the command that follows.
Notes: 'dir' is an alias of 'Get-ChildItem'. See: wiki: cmdlets.
One can provide further functionality. e.g. 'dir -recurse' outputs all the files, folders and sub-folders.
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.
The problem with the two Powershell answers here is that the prefix can end up being duplicated since the script will potentially run over the file both before and after it has been renamed, depending on the directory being resorted as the renaming process runs. To get around this, simply use the -Exclude option:
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.
Based on @ofer.sheffer answer this command will mass rename and append the current date to the filename. ie "file.txt" becomes "20180329 - file.txt" for all files in the current folder
for %a in (*.*) do ren "%a" "%date:~-4,4%%date:~-7,2%%date:~-10,2% - %a"
I was tearing my hair out because for some items, the renamed item would get renamed again (repeatedly, unless max file name length was reached). This was happening both for Get-ChildItem and piping the output of dir. I guess that the renamed files got picked up because of a change in the alphabetical ordering. I solved this problem in the following way:
This "locks" the results returned by Get-ChildItem in the variable $dirs and you can iterate over it without fear that ordering will change or other funny business will happen.
Dave.Gugg's tip for using -Exclude should also solve this problem, but this is a different approach; perhaps if the files being renamed already contain the pattern used in the prefix.
Based on @ofer.sheffer answer, this is the CMD variant for adding an affix (this is not the question, but this page is still the #1 google result if you search affix). It is a bit different because of the extension.
For anyone using PowerShell with this same requirement (adding a prefix to a file name in a directory), you will likely find that if you use some form of...
...that the files will continually get the prefix added in a loop until the windows file name length limit is reached. So instead of "prefixFile1.txt" you get: "prefixprefixprefixprefixprefixprefix...File1.txt". The cause of this is Get-ChildItem cmdlet will continually pipe the newly named file back into the Rename-Item cmdlet.
Putting $() around a Get-ChildItem ensures that all of the currently existing files get returned first and are then piped into Rename-Item, rather than piped in dynamically without the subexpression operator. Just keep in mind if you have millions+ files/items as it may take awhile to iterate all of them before any renames are carried out.