0

Here is my another challenge. When I pass the file name into for loop, I want to get a specific word from the file name and need to pass that as a parameter as well.

For eg: When there are 5 files in a folder say

Encrypted_abc_1.xml Encrypted_xyz_2.xml Encrypted_hij_3.xml Encrypted_klm_4.xml Encrypted_nop_5.xml

I want to pass the file name Encrypted_abc_1.xml and abc into the for loop. I got the answer for both in seperate for loops however how can i merge into one single for loop

First for loop will fetch the word

for /f "tokens=2 delims=_." %%a in (Encrypted_*.xml /b) do (

Echo %%a

Another for loop will get the full file name

for /R "%Path%" %%f in (Encrypted_*.xml) do (

Echo %%f
1
Contributor
1
Reply
4
Views
3 Years
Discussion Span
Last Post by divakar.it
0

Below is the revised code as of now but still it doesnt work as Path is not recognised

@ECHO OFF
SET Path=%1

SET Path=%Path:"=%
Echo "%Path%"
::SETLOCAL

for /f "tokens=*" %%a in ('%Path% /b Encrypted*.xml') do (
     for /f "tokens=2 delims=_" %%f in ("%%a") do (
    Echo %%f
    ECHO %%a
)
)

Pause:
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.