How do I prepend a string or character to a number of file names in Windows?
PowerShell is the answer!
Hold Shift and right-click in open space in the Explorer window where you can see your files and select "Open PowerShell window here": In the resulting window use the following statement:
ls | Rename-Item -NewName {"-" + $_.name}
What's happening is the ls
command is passing its output (list of files in that directory) to the Rename-Item
command, where the name structure is specified in the braces {}
. In PowerShell $_
is a placeholder for whatever object is currently being processed, in this case each file. In this way we can quickly and easily prepend any string to the filename.
Here's PowerShell in action:
A word of caution - this command will make this change to all files contained in this folder. If you only want to make this change to a subset of files, I would suggest (A) moving the files into their own folder before doing this or (B) filtering the list of files further in PowerShell, explained below:
Renaming Text files only, and excluding the RTF document: This is the statement:
ls *.* -Include *.txt | Rename-Item -NewName {"-" + $_.name}
The syntax is slightly different - we need to specify the Path and all viable files *.*
which we then filter down using -Include *.txt
. From there the process is the same.
This would also work, and I prefer it actually:
ls *.txt | Rename-Item -NewName {"-" + $_.name}
Unfortunately, I am not sure there is a simple way to do this from File Explorer itself.
Instead, I might suggest using a program called Bulk Rename Utility. It's free for personal, non-commercial use and while its interface may look slightly daunting, it's relatively easy to use in most cases.
If you wish to give it a try, please follow these steps:
Download and install Bulk Rename Utility. If you only need to use it temporarily (e.g. just for this one task) or cannot install software, there is a portable "No Installer" version as well.
-
Open the program and navigate to the folder containing your files. You can either type a direct path (after which, you would press Enter) or you can use the folder tree in the upper left to navigate your through your folders:
-
In middle-right portion of the Bulk Rename Utility window, look for the option marked
Add (7)
and type a-
in thePrefix
field: -
Towards the bottom left, find the option marked
Filters (12)
and uncheck theFolders
checkbox item:Once you do this, any folders in the directory will no longer be displayed in the main file window:
-
From the main menu bar, select Actions → Select All (or press Ctrl + A). All the currently visible files in the working directory should be highlighted in blue, with a preview of the new file names appearing in green under the
New Name
column: Assuming you are happy with the
New Name
results, press the large Rename button in the lower right. Press OK in the warning dialog to confirm you wish to rename the files.
If you make an option mistake you can't correct (before the rename is applied), you can select Actions → Reset All Naming Criteria (or press Ctrl + T) to return all the options to their default states.