Section 1 - Renaming files with Bulk Rename Utility.
Section 2 - Suggestions regarding grouping files to make processing easier.
Section 3 - Searching for files with spaces in their names just before the extension.
Section 4 - Exporting a list of those files as a text file.
Using Bulk Rename Utility
As I understand it, you were having some small issues with Bulk Rename Utility.
Assuming your description is accurate (and there is simply one or more spaces as the last characters before the extension e.g. "ba room 56 .xxx"), then you can simply use the
Trim function in
Remove (5) without changing any options:
ex. Preview Results
To be clear:
You will note that only the names to be changed will appear in green. Likewise, this will only rename files, not folders. Once satisfied, click the Rename button in the lower right corner.
If desired, you can reset the entire renaming criteria window (in case you have been fooling around with other options or just feel cautious) with Actions → Reset All Renaming Criteria ( Ctrl+T ).
Bulk Rename Utility normally operates on only a single root folder at a time. However, it is possible to include sub-directories:
ex. Replacements In Sub-Directories
You can include these folders by using the
Filters (12) section of the main window. Simply mark
ex. Filter Options
I have also unchecked
Folders to reduce visual clutter in the preview window (our use of
Trim, as already noted, doesn't affect folders either way). After you have selected the proper filter options, use Select All,
Trim and Rename as above.
Grouping Files With Spaces
In your case, Bulk Rename Utility has the ability to identify the correct file names to be modified without additional action (just point it at the proper directory containing those files). Files that don't match your criteria are automatically ignored.
However, as you point out, there are a large number of files and Bulk Rename Utility might have difficulty with processing all of them at once. As a suggestion, I might consider grouping files into temporary directories with about 50-100 files each.
While I do suggest a batch file to assist you below, it doesn't group files by a specific number. You will still have to create new directories and do that portion manually if you so choose. Similarly, it requires you to move and run it one folder at a time.
Batch File Sorting
To help generally ease the task of processing such a large number of files, you can sort out files containing spaces just before the extension with a batch file:
Open a new document in Windows Notepad and copy the following lines:
if not exist %~dp0tempspace md %~dp0tempspace
move /-y %~dp0"* .*" %~dp0tempspace
Choose Save As and under
Save as type, choose
All Files (*.*).
Change your document extension to
.bat (Windows batch file) by typing e.g. findspaces.bat.
If done correctly, the file name should change to include the
.bat extension and the icon for the new file should change to a box with gears in Explorer (rather than a sheet of paper).
Place this batch file in any folder you believe may have files with spaces just before the extension and double click to run it. Any matching files will moved to a new folder called e.g. tempspace. Repeat as necessary for additional folders and sub-directories, moving the batch file each time.
Batch File Notes
This batch file doesn't search sub-directories (as implied above).
It moves all matching files to the given temporary directory (not just some).
You can replace e.g. tempspace with any folder name you like, but I would avoid spaces. Likewise, mind the lack of space between
%~dp0 and the folder name.
Instead of all files with spaces just before the name (
"* .*"), you can use a specific extension if you wish (e.g.
"* .xxx"). Again, mind the lack of space between
%~dp0 and your search criteria, as well as the space between the first asterisk and the period.
While this shouldn't apply to saving new files, you may have to unhide extensions in Windows to change existing text files to a
Searching For Files
Since it may be helpful (but not necessarily needed) to know ahead of time which files contain spaces just before the extension, here are my thoughts regarding that topic...
There are a large number of utilities which could assist you. That said, regarding native Windows solutions, there is the find command line utility but I don't believe it has the capability you need. Similarly, I have never been a fan of Windows Search and I would be dubious about its helpfulness in your situation.
As an simple alternative, I would recommend Mythicsoft's Agent Ransack. It is a free file search program which you can download here. Note that you currently don't have to worry about "registering" the program as a home user (it will work regardless).
Once installed, open Agent Ransack and enter in the following in the main search window:
* .* in the
File name field to search for all files with one or more leading spaces just before the extension. As with the batch file above, remember the space between the first asterisk and the period. You can, of course, specify an extension again as well e.g.
Make sure the proper root folder (e.g. your game files folder) appears in the
Look in field.
If you want to do a comprehensive search, you should check
Start button on the right to begin searching for files. Once the search is finished, you should see results similar to the following:
ex. Search Results
While my example image shows only a single directory, your real results will show full paths including sub-directories (assuming you marked
Exporting A List Of Files
To get a list of the Agent Ransack search results as a text file, you can export them with File → Export results... or use the
Export results icon on the Agent Ransack toolbar:
ex. Export Results
In the Export window, make sure to save the results as a text file by:
Setting an export path with an appropriate file name.
Selecting "Textfile" for the
Save results for: All files is marked.
Click the Export button in the lower right once finished.
ex. Export Window
Cleaning Things Up With Notepad++
Unfortunately, besides the full path and file name, the exported list comes with information you likely don't need e.g.:
C:\path\to\gamefiles\ba room 56 .xxx 1 KB XXX File 2/11/2018 11:56:11 PM [...]
To keep the path/file information and discard the rest, we can use a free text editor called Notepad++ (not to be confused with regular Windows Notepad). Simply select either the 32-bit or 64-bit installer on the Download page.
Once installed, open your e.g. SearchResults.txt file in Notepad++. From the menu, select Search → Replace... ( Ctrl+H ) to bring up the Replace dialog.
You can then use a regular expression (a special search pattern) to highlight the information you don't need. Type the following in the
Find what : field:
Replace with : field blank. Make sure that the
Wrap around and
Regular expression options are all marked. The
. matches newline option should be unchecked:
ex. Notepad++ Replace Dialog
Once you are ready, click Replace All on the right. You can then save the edited file, assuming everything looks correct.
List Editing Notes
Please keep in mind that the regular expression I suggest for removing data could likely stand a little tweaking, but it should work correctly for text generated by Agent Ransack. Let me know if you encounter any issues.
This edited list could be the input for some other script. If you wish to use it in this fashion, it would probably be best to remove any blank lines. You can do this manually or Notepad++ can do this for you with Edit → Line Operations → Remove Empty Lines.
Removing blank lines also avoids an issue with quoting (normally invisible) lines that consist solely of spaces (assuming you wish to use the regular expression for quoting lines, below).
Quoting paths in this list should not be necessary in most instances (even if the paths in the list contain spaces). But if you do find you need each path in the list quoted for some reason, you can use Notepad++ for this as well. Simply open the Replace dialog with regular expressions again (with the same settings as above) but use
(.+) in the
Find what : field and
"\1" in the
Replace with : field: