" Matthieu" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hello,
>
> I have a directory with some files in it, actually .xls files.
> I need to figure out if the content of thoses files is the same or not,
> and
> if it's the same move it to an new folder.
>
> Is it possible to script that ?
> Can someone help me ?
>
> Cheers,
> MAtthieu
>
>
You'd possibly get a better response at alt.msdos.batch.nt
Meanwhile, try this - assuming that you mean "move any (.xls) files where
there is an identical (.xls) file in the directory to another directory":
--- mdf.bat begins ---
[01]@echo off
[02]:: are there any .xls files in the source directory?
[03]if not exist *.xls goto :eof
[04]:: need to establish a Temporary File
[05]set ytf=d
[06]:tfloop
[07]if exist %temp%\%ytf%* set ytf=%ytf%f&goto tfloop
[08]set ytf=%temp%\%ytf%
[09]:: find all .xls files in source directory, and their sizes
[10]for /f %%i in ('dir /b /a:-d *.xls') do echo %%~zi %%i>>%ytf%1
[11]for /f "tokens=1*" %%i in (%ytf%1) do for /f "tokens=1*" %%I in (%ytf%1)
do if %%I==%%i if not "%%J"=="%%j" set yf1=%%j&set yf2=%%J&call :movedupe
[12]:: clean up tempfile and environment variables
[13]del %ytf%*
[14]for %%i in (ytf yf1 yf2) do set %%i=
[15]goto :eof
[16]
[17]:movedupe
[18]:: file may have already been moved
[19]if not exist "%yf1%" goto :eof
[20]if not exist "%yf2%" goto :eof
[21]:: compare 2 same-size files
[22]fc /b "%yf1%" "%yf2%" >nul
[23]:: errorlevel is zero if they are identical
[24]if errorlevel 1 goto :eof
[25]if exist "\destdir\%yf2%" echo Cannot move "%yf2%"&goto :eof
[26]move "%yf2%" \destdir
[27]goto :eof
--- mdf.bat ends ---
Each line begins [number]. Lines will be wrapped in transmission and need to
be rejoined. The [number] at the beginning of each line needs to be removed.
Note the use of %%i and %%I because the process applied to each is similar.
In this case, the program IS case-sensitive.
HTH
....Bill
|