Click here to Skip to main content
15,888,286 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I am trying to prepare a batch script which can extract code number from all the files into a list file. There are multiple files in the folder and only the code from the file should go to the list.

Ex:
ABC_11223344_NEO.txt
ABC_21223344_NEO.txt
ABC_31223344_NEO.txt

the list file should contain
11223344
21223344
31223344

What I have tried:

Looking for batch script to be run on windows
Posted
Updated 14-Jun-18 6:43am

1 solution

Create the following script and save it as list.cmd:
@ECHO OFF
SETLOCAL
SET fnm=%1
SET cfn=%fnm:.txt=%
set cfn=%cfn:~4,8%
echo %cfn%
ENDLOCAL

Run the command:
for %x in (*.txt) do list %x

You can pipe the output into a file to save the list.
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900