Without being able to test, I believe that using the where
command, (Windows Vista onwards), should ignore those 8.3 filenames:
@For /F "EOL=| Delims=" %%G In ('%__AppDir__%where.exe^
C:\mPodcasts\ipod:s*.lnk^
C:\mPodcasts\ipod:ta*.lnk^
C:\mPodcasts\ipod:te*.lnk^
C:\mPodcasts\ipod:tha*.lnk^
2^>NUL') Do @Echo %%G
@Pause
For the purposes of your provided information, the above should work without modification. However, should your directories or file pattern contain spaces, problematic characters, you can also doublequote them as necessary:
@For /F "EOL=| Delims=" %%G In ('%__AppDir__%where.exe^
"C:\mPodcasts\ipod":"s*.lnk"^
"C:\mPodcasts\ipod":"ta*.lnk"^
"C:\mPodcasts\ipod":"te*.lnk"^
"C:\mPodcasts\ipod":"tha*.lnk"^
2^>NUL') Do @Echo %%G
@Pause
I hope this helps.
BTW, this solution also solves the other issue mentioned in the question you linked in your post above. The where
command does not output extensions 'beginning with', it properly matches it. Taking the linked 'discussion' question as a basis, *.htm
only matches .htm
extensions, (it does not include .html
), and *.man
does not match .manifest
extensions.
If you wish to test the output directly in your cmd.exe window, then here's the single line version:
For /F "EOL=| Delims=" %G In ('%__AppDir__%where.exe C:\mPodcasts\ipod:s*.lnk C:\mPodcasts\ipod:ta*.lnk C:\mPodcasts\ipod:te*.lnk C:\mPodcasts\ipod:tha*.lnk 2^>NUL') Do @Echo %G