Reputation: 53
I am struggling to write a batch file to get a specific name from file name.
There are several xml files in a folder and all looks like the below
Plaintext1.xml
Plaintext2.xml
Plaintext3.xml
Encrypted_abcd_1_xml
Encrypted_samp_2.xml
Encrypted_xyz.xml
..
I want to get only files starts with Encrypted_*.xml and in the list of these files I want to get only word abcd, samp, xyz. i.e before symbol '' and after symbol ''.
Can you please provide some samples?
I have written upto this
@ECHO OFF
Z:
cd "C:\temp\"
for %%f in (Encrypted_*.xml) do (
Echo %%f
Echo x
)
:DONE
PAUSE:
Upvotes: 0
Views: 66
Reputation: 7117
This should do it:
@echo off
setlocal
cd /d "C:\temp"
for /f "tokens=2 delims=_." %%a in ('dir Encrypted_*.xml /b ') do echo %%a
Upvotes: 2