处理具有相同前缀的相同文件 [英] processing same files with same prefix
本文介绍了处理具有相同前缀的相同文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的dir.lst如下:
************************ *
wady0_Hold.out.new
wady0_Post.out.new
wady2_Hold.out.new
wady2_Post.out.new
wady3_Post.out.new
wady4_Hold.out.new
但是我可以看到新创建的文件是在具有相同名称的旧文件上创建的。这违反了上面写的语法????
My dir.lst as like this :
*************************
wady0_Hold.out.new
wady0_Post.out.new
wady2_Hold.out.new
wady2_Post.out.new
wady3_Post.out.new
wady4_Hold.out.new
But I can see that the new created files are created over the old ones with the same names . That is against the syntax written above ????
dir /b %folder%\*.out.new > dir1.lst
@echo off
for /f "tokens=1,* delims=_" %%a in (dir1.lst) do (
echo %%a
::for missing pairs
if not exist %folder%\%%a_Post.out.new copy nul %folder%\%%a_Hold.out.new
if not exist %folder%\%%a_Hold.out.new copy nul %folder%\%%a_Post.out.new
pause ""
)
推荐答案
我怀疑你无意中越过了你的文件名。试试这个:
I suspect you inadvertently crossed over your file names. Try this:
if not exist %folder%\%%a_Post.out.new copy nul %folder%\%%a_Post.out.new
if not exist %folder%\%%a_Hold.out.new copy nul %folder%\%%a_Hold.out.new
这篇关于处理具有相同前缀的相同文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文