我必须在两个文件夹中比较文件,例如
folderA:[a.f90,b.f90,...] folderB:[a_recoded.f90,b_recoded.f90,...]
我希望将folderA中的a.f90与folderB中的a_recoded.f90进行比较。
使用的是:
@echo off
set folderA=D:\folderA
set folderB=D:\folderARenamed
set /a i=0
set /a j=0
cd %folderA%
FOR %%f in (*.f90) DO ( set /a i+=1 & for %%r in (%folderB%\*.f90) DO (set /a j+=1 & if %i% EQU %j% FC %%f %% r ) )
这对我没有帮助,任何人都可以帮我解决这个问题。
答案 0 :(得分:2)
试试这个:
@echo off &setlocal
set "folderA=D:\NONMEM7.3beta7.0"
set "folderB=D:\NONMEM7.3beta7.0Renamed"
for %%a in ("%folderA%\*.f90") do if not exist "%folderB%\%%~na_recoded%%~xa" echo %%~na_recoded%%~xa not found in %folderB%.
for %%a in ("%folderB%\*.f90") do for /f "delims=_" %%b in ("%%~na") do if not exist "%folderA%\%%~b%%~xa" echo %%~b%%~xa not found in %folderA%.
答案 1 :(得分:0)
感谢您的帮助,现在我还使用以下代码遍历文件夹:
@echo off
set vss=D:\FolderA
set renamed=D:\FolderARenamed
cd %renamed%
FOR /D %%d in (*) DO (
cd %renamed%\%%d
FOR %%f in (*.f90, *.f, *.c) DO (
if exist %vss%\%%d\%%f fc %%f %vss%\%%d\%%f
if not exist %vss%\%%d\%%f fc %%f %vss%\%%d\%%~nf_Recoded.f90
)
)