1.

Solve : extract the filename alone from path?

Answer» PROBLEM: I need to EXTRACT the only the filename from path ,by inputing the list of path NAMES through the text FILE.

I use the following loop . I use delim as \

Input file: cer_pem_certs.txt
C:\Documents and Settings\anithya\ApplicationData\Sun\Java\Deployment\security\deployment.certs
C:\Program Files\InterCall Web Meeting\Client\cert.pem


FOR /F "tokens=5 delims=\" %%a in (cer_pem_certs.txt) do @echo %%a > Cer_Name.txt

Problem - I need to extract data on last occurence of the delimiter(i mean only file name) .The levels of path name is irregular and it doesnt apply to all PATHS when i use fixed positions (tokens=5). Please advice how to extract the filename alone.Code: [Select]FOR /F "delims==" %%a in (cer_pem_certs.txt) do @echo %%~nxa >> Cer_Name.txt
Note: you need to use the >> redirection symbols, and not just >, or Cer_name.txt will only have 1 line, (the last filename from cer_pem_certs.txt)

see FOR /? for explanation of variable modifiers.


Discussion

No Comment Found