1.

Solve : get file name in ms-dos batch program?

Answer»

hi? how are you?  
I want to get file NAME in ms-dos batch program  
but I want to apart of file name.  
for example,    
 
   c:\kk\20041220\CGAA0_ROLE_20041220.txt  
     
---> I want to get  " CGAA0 " then  
 INSERT below variable XXX  
 
ECHO open 111.111.44.78 > FTPHEAD.SCR  
ECHO lsy>> FTPHEAD.SCR  
ECHO lsy01>> FTPHEAD.SCR  
ECHO bi >> FTPHEAD.SCR  
ECHO hash >> FTPHEAD.SCR  
ECHO prompt >> FTPHEAD.SCR
 
ECHO put  XXX_ROLE_20041220.txt >> FTPHEAD.SCR  

ECHO bye >> FTPHEAD.SCR  
ftp -s:FTPHEAD.SCR > Dashboard_Log_quit_20041220.logTry something like this:

CODE: [Select]set v=c:\kk\20041220\CGAA0_ROLE_20041220.txt
for /f "tokens=4 delims=_\" %i in ("%v%") do echo %i
The for loop breaks the variable v into several pieces, separated by either _ or \. It then assigns the 4th piece to the variable i.

Good luck,
[GLB]cs[/glb]Remember in DOS, filenames are limited to 8 charectors in length, plus 3 for an extention.



Discussion

No Comment Found