0

We have a log file like below.

I need a batch script to display the output from /soft. i.e., the output must look like:

SOFT\MAIN\Core\RADXML\ICCREFPX_RAD.xml

It should not display the whole path.

The script should read the log files from D:\custom.txt and print the output to different file like SOFT\MAIN\Core\RADXML\ICCREFPX_RAD.xml

=========================================================================== 
                               Custom FILES                                 
=========================================================================== 
Z:\FCUBS_11.3.1.1.0EURABOILM_SKD\02-07-2012_2108\SOFT\MAIN\Core\RADXML\ICCREFPX_RAD.xml
Z:\FCUBS_11.3.1.1.0EURABOILM_SKD\02-07-2012_2108\SOFT\MAIN\Core\RADXML\ICDREDMN_RAD.xml
Z:\FCUBS_11.3.1.1.0EURABOILM_SKD\05-07-2012_1950\SOFT\MAIN\Core\RADXML\ICCREFPX_RAD.xml
Z:\FCUBS_11.3.1.1.0EURABOILM_SKD\05-07-2012_1950\SOFT\MAIN\Core\RADXML\ICDREDMN_RAD.xml
Z:\FCUBS_11.3.1.1.0EURABOILM_SKD\06-07-2012_1949\SOFT\MAIN\Core\RADXML\ICDREDMN_RAD.xml
Z:\FCUBS_11.3.1.1.0EURABOILM_SKD\09-07-2012_1948\SOFT\MAIN\Core\RADXML\ICCREFPO_RAD.xml
Z:\FCUBS_11.3.1.1.0EURABOILM_SKD\09-07-2012_1948\SOFT\MAIN\Core\RADXML\ICDREDMN_RAD.xml
Z:\FCUBS_11.3.1.1.0EURABOILM_SKD\11-07-2012_1946\SOFT\MAIN\Core\RADXML\ICCREFPO_RAD.xml
Z:\FCUBS_11.3.1.1.0EURABOILM_SKD\11-07-2012_1946\SOFT\MAIN\Core\RADXML\ICDREDMN_RAD.xml
Z:\FCUBS_11.3.1.1.0EURABOILM_SKD\17-07-2012_1942\SOFT\MAIN\Core\RADXML\ICDREDMN_RAD.xml
Z:\FCUBS_11.3.1.1.0EURABOILM_SKD\19-07-2012_1938\SOFT\MAIN\Core\RADXML\ICCREFPO_RAD.xml
Z:\FCUBS_11.3.1.1.0EURABOILM_SKD\23-07-2012_1939\SOFT\MAIN\Core\RADXML\ICCREFPO_RAD.xml
Z:\FCUBS_11.3.1.1.0EURABOILM_SKD\23-07-2012_1939\SOFT\MAIN\Core\RADXML\ICDREDMN_RAD.xml
4

2 回答 2

1
@echo off
setlocal enableDelayedExpansion
>modified.log (
  for /f "delims=" %%A in (original.log) do (
    set "ln=%%A"
    echo !ln:*\SOFT\=SOFT\!
  )
)

FOR /F 语句读取并处理文件中的所有行。FOR /?您可以通过键入或HELP FOR从命令行来阅读它。

关键位是!ln:*\SOFT\=SOFT\!- 在文本中搜索“\SOFT\”,并删除从行首到“\SOFT\”的所有内容,并将删除的位替换为“SOFT\”。SET /?您可以通过键入或HELP SET从命令行阅读有关字符串搜索和替换的信息。

于 2012-09-06T11:47:21.027 回答
0

一个班轮:

D:\>FOR /F "tokens=4,5,6,7,8 delims=\\" %G in (infile.txt) DO @echo %G\%H\%I\%J\%K

SOFT\MAIN\Core\RADXML\ICCREFPX_RAD.xml
SOFT\MAIN\Core\RADXML\ICDREDMN_RAD.xml
SOFT\MAIN\Core\RADXML\ICCREFPX_RAD.xml
SOFT\MAIN\Core\RADXML\ICDREDMN_RAD.xml
SOFT\MAIN\Core\RADXML\ICDREDMN_RAD.xml
SOFT\MAIN\Core\RADXML\ICCREFPO_RAD.xml
SOFT\MAIN\Core\RADXML\ICDREDMN_RAD.xml
SOFT\MAIN\Core\RADXML\ICCREFPO_RAD.xml
SOFT\MAIN\Core\RADXML\ICDREDMN_RAD.xml
SOFT\MAIN\Core\RADXML\ICDREDMN_RAD.xml
SOFT\MAIN\Core\RADXML\ICCREFPO_RAD.xml
SOFT\MAIN\Core\RADXML\ICCREFPO_RAD.xml
SOFT\MAIN\Core\RADXML\ICDREDMN_RAD.xml
于 2012-09-06T11:48:35.457 回答