从文件夹中的文件中提取代码 [英] Extract code from files in a folder
问题描述
我正在尝试准备一个批处理脚本,它可以将所有文件中的代码编号提取到列表文件中。文件夹中有多个文件,只有文件中的代码才能进入列表。
Ex:
ABC_11223344_NEO.txt
ABC_21223344_NEO.txt
ABC_31223344_NEO.txt
列表文件应该包含
11223344
21223344
31223344
我的尝试:
寻找在Windows上运行的批处理脚本
创建以下脚本并将其另存为list.cmd :
@ ECHO OFF
SETLOCAL
SET fnm =%1
SET cfn =%fnm:.txt =%
set cfn =%cfn:~4,8%
echo%cfn%
ENDLOCAL
运行命令:
for%x in(* .txt)do list%x
您可以将输出通过管道传输到文件中以保存列表。
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
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.
这篇关于从文件夹中的文件中提取代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!