|
Answer» I see how you can IGNORE the case of the letter in the file NAME, but I actually want a list of all file names in a folder, that have a capital letter in them.
We have a subversion issue, where some of the developers have created all capital file extensions, first letter capital in the file name... and so on.
As opposed to clicking through 500 folders, (exaggeration) I was hoping there was a way to query this into a list.
Note: a simple file name change will only hurt at this point. I need to open each file and change the way the file name is saved in the form or report. Hence, the need for a list.
If this cannot be done on a command prompt, any suggestions would be much appreciated.
Thank you, RyanDo you want just the file name & extension as output, or the full driveletter and path as well? The script snippet below shows how to get either.
contents of folder Code: [Select]Capital1.txt CAPITAL2.txt caPital3.txt capital4.TXT capital5.Txt capital6.TxT lower1.txt lower2.txt lower3.txt simple batch script showing how to pipe DIR output through findstr using regex
In case any aspiring regex wizards decide to query my code, the regular expression implementation in Windows Findstr behaves in a nonstandard way when processing alphabetic ranges e.g. [A-Z] which is why I have used the less compact [ABCDEFGHIJKLMNOPQRSTUVWXYZ].
Code: [Select]@echo off SET folder="c:\Batch\Test\After 04-07-2012\findcapital" for /f "delims=" %%A in ( ' dir /b %folder% ^| findstr /R "[ABCDEFGHIJKLMNOPQRSTUVWXYZ]" ' ) do ( echo full path %%~dpnxA echo just name %%~nxA echo. )
Output: Code: [Select]full path c:\Batch\Test\After 04-07-2012\findcapital\Capital1.txt just name Capital1.txt
full path c:\Batch\Test\After 04-07-2012\findcapital\CAPITAL2.txt just name CAPITAL2.txt
full path c:\Batch\Test\After 04-07-2012\findcapital\caPital3.txt just name caPital3.txt
full path c:\Batch\Test\After 04-07-2012\findcapital\capital4.TXT just name capital4.TXT
full path c:\Batch\Test\After 04-07-2012\findcapital\capital5.Txt just name capital5.Txt
full path c:\Batch\Test\After 04-07-2012\findcapital\capital6.TxT just name capital6.TxTI will have to look up those echo parameters so I understand more about the output. Either way, I like your idea.
Thank you for this, I will give it a shot right now.Quote from: YeeP on August 01, 2012, 02:42:47 PM I will have to look up those echo parameters so I understand more about the output.
if %%A is a file name %%~dA is the drive, %%~pA is the path, %%~nA is the bare name and %%~xA is the extension. You can combine them so %%~dpnxA is the whole drive letter, path and name.
|