Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: batch DOS
How to get the letters/word in a filename?
 
For Example: 2012P02B.xml - i just want to get the letters: "P02B"
 
Please help me. Thanks and Regards!
Posted 5-Dec-12 20:25pm
Comments
bopannavb at 6-Dec-12 4:14am
   
can you be specific in what format you need the letters/word like you don't need the number and the extension or any thing specific

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

What do you mean by "get"? ECHO? Write to a file? Load into a variable?
To get echo, try this:
DIR 2012*.XML /B > TEST.TXT
for /F "eol=. tokens=2 delims=2." %i in (test.txt) do @echo %i
The first line creates a text file with bare names of all matching files.
The second line runs on the text file, splitting it into 'tokens' each time it finds a 'delimiter'.
The delimiters are 2 and dot.
If your file is 2012p03b.xml, the tokens would be: 2012p03b.xml.
The second token (%i) would be p03b.
 
Hope this points you in the right direction,
 
Pablo.
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 350
1 Jochen Arndt 190
2 Richard MacCutchan 135
3 Sergey Alexandrovich Kryukov 130
4 DamithSL 95
0 OriginalGriff 6,045
1 DamithSL 4,601
2 Maciej Los 4,087
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,310


Advertise | Privacy | Mobile
Web03 | 2.8.141220.1 | Last Updated 6 Dec 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100