Link to home
Start Free TrialLog in
Avatar of thandel
thandel

asked on

Find files based on lack of space in file names

I have a large directory with over 10,000 files... the are in a common file naming convention of:

[Last name], [firstname] [year]-[month] [characters]
EX Smith, J 2019-10 MMC

Wanted to display only the file names that do NOT have a space after the coma after the last name Ex "Smith,J 2019-10 MMC"

Is this possible and if so perhaps a view in Windows 10 File explorer.

Thank you.
Avatar of Jaroslav Mraz
Jaroslav Mraz
Flag of Slovakia image

search *],[*
Avatar of Bill Prew
Bill Prew

Easy enough at a DOS command prompt.  Change to the folder you want to search, and then do:

dir /b | find /v ", " > files.txt

"files.txt" will have a list of the names of the files that don't have a comma followed by a space.


»bp
Get-ChildItem "Folderlocation" | Where-Object {$_.Name -notLike "*, *"}

Open in new window



Powershell version
For the fun of it, here's some PowerShell with a RegEx that verifies the complete pattern:
Results will end up in a csv defined in the last line:
Get-ChildItem "C:\Some\Directory" -File |
	Where-Object {$_.BaseName -notmatch '^\S.*?, \S(.*?\S)? (19|20)\d{2}-(0|1)\d \S.*'} |
	Select-Object -Property Name, FullName, LastWriteTime |
	Export-Csv -NoTypeInformation -Path C:\Temp\WrongFormat.csv

Open in new window

If you want to see the results immediately in a GUI with the option to search further:
Get-ChildItem "C:\Directory" -File |
	Where-Object {$_.BaseName -notmatch '^\S.*?, \S(.*?\S)? (19|20)\d{2}-(0|1)\d \S.*'} |
	Select-Object -Property Name, FullName, LastWriteTime |
	Out-GridView

Open in new window

Avatar of thandel

ASKER

Thanks for all the solutions... I needed it in explorer so once found I can modify the file name.  I tried:

Jaroslav Mra's solution of "*],[*" in the search box but did found many files that didn't meet the criteria.

Alex - that didn't seem to work in explorer's search either

OBda- Hoping for a solution in windows explorer not a list of sorts

Bill - Can this be implemented some how with Windows Explorer?
ASKER CERTIFIED SOLUTION
Avatar of Alex
Alex
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
You're getting scripts as suggestions because the Explorer filtering capabilities are, to put it mildly, somewhat limited.
If you need this kind of search more often, have a look at Everything; the results offer the full Explorer context menu.
Everything > Locate files and folders by name instantly.
https://www.voidtools.com/faq/
+1 for Everything as a way to find files based on name, it's a great tool that I have running all the time and helps me instantly track down files.


And if your ultimate goal is the rename certain files based on their existing names, take a good look at Bulk Rename Utility.  It can likely do it all in one step and is a great tool for renaming many files at once, based on patterns and logic.



»bp
You can do that in powershell as well :-)