0

I have to compare the file in two folders which have file names like

folderA: [a.f90, b.f90, ...] folderB: [a_recoded.f90, b_recoded.f90, ...]

I wish to compare a.f90 in folderA with a_recoded.f90 in folderB.

what is used is:

@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 ) )

It doesn't help me, can anyone help me how to do this comparsion.

2
  • Why this is not working? set /a i=0 set /a i+=1
    – Thiru
    Oct 1, 2013 at 11:31
  • It strikes me that if the files are recoded, they aren't going to be the same.
    – foxidrive
    Oct 1, 2013 at 12:19

2 Answers 2

2

try this:

@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
  • 1
    +1 This looks good to tell if the files exist or not - I thought the OP wanted to do a binary compare. It's not clear.
    – foxidrive
    Oct 1, 2013 at 12:22
0

Thank for the help, now I use the following code to loop through the folders also:

@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
   )
)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.