Jump to content

Welcome to MSFN Forum
Register now to gain access to all of our features. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more. This message will be removed once you have signed in.
Login to Account Create an Account


Photo

Batch file for searching for file duplicates

- - - - -

  • Please log in to reply
2 replies to this topic

#1
FixitUP

FixitUP

    Newbie

  • Banned
  • 47 posts
  • OS:XP Pro x86
  • Country: Country Flag
It took around 4.5 seconds to find 2 identical search.bat files in different directories using s*.bat as the search pattern.

What do I have to do to have it work like this ?

search.bat s*.asm without the search pattern being hard coded into the batch file.

I recall using %1.

:: Search.bat Dave Benham, mousio, Magnum,skywalker,
::

cls
@echo off
echo.
echo Timer has started.
echo.
call :StartTimer
::
:: Add your script functionality here
::
@echo off
setlocal disableDelayedExpansion
set "searchRoot=."
set "fileMask=s*.bat"

set "prior=noMatch"
for /f "tokens=1,2 delims=?" %%A in (
'(for /r "%searchRoot%" %%F in ("%fileMask%"^) do @echo %%~zF:%%~nxF?%%~fF^)^|sort'
) do (
set "current=%%A"
setlocal enableDelayedExpansion
if !prior! equ !current! (
if defined priorFile (
echo(
echo !priorFile!
)
endlocal
echo %%B
set "priorFile="
) else (
endlocal
set "prior=%%A"
set "priorFile=%%B"
)
)

call :StopTimer
call :DisplayTimerResult
pause
goto :EOF

:StartTimer
:: Store start time
set StartTIME=%TIME%
for /f "usebackq tokens=1-4 delims=:., " %%f in (`echo %StartTIME: =0%`) do set /a Start100S=1%%f*360000+1%%g*6000+1%%h*100+1%%i-36610100
goto :EOF

:StopTimer
:: Get the end time
set StopTIME=%TIME%
for /f "usebackq tokens=1-4 delims=:., " %%f in (`echo %StopTIME: =0%`) do set /a Stop100S=1%%f*360000+1%%g*6000+1%%h*100+1%%i-36610100
:: Test midnight rollover. If so, add 1 day=8640000 1/100ths secs
if %Stop100S% LSS %Start100S% set /a Stop100S+=8640000
set /a TookTime=%Stop100S%-%Start100S%
set TookTimePadded=0%TookTime%
goto :EOF

:DisplayTimerResult
:: Show timer start/stop/delta
echo Started: %StartTime%
echo Stopped: %StopTime%
echo Elapsed: %TookTime:~0,-2%.%TookTimePadded:~-2% seconds
goto :EOF


How to remove advertisement from MSFN

#2
bphlpt

bphlpt

    MSFN Addict

  • Members
  • PipPipPipPipPipPipPip
  • 1,634 posts
  • OS:none specified
  • Country: Country Flag
Are you really wanting to code your own duplicate finder script? Out of curiosity, why? Wouldn't just using one of the many free duplicate finder programs be easier and faster? What are you really trying to accomplish?

Cheers and Regards

#3
Yz÷wl

Yz÷wl

    Wise Owl

  • Super Moderator
  • 4,506 posts
  • OS:Windows 7 x64
  • Country: Country Flag

Donator

You do realise of course that the code does not find identical files, it finds same name files with same filesizes; there is a difference!

Andy, I'd appreciate it if you exhaused one avenue before taking another, it isn't nice to post code between forums simultaneously. You've posted Daves code from the other forum here and at least gunsmokingmans from another of your Topics here, under the name smokingmangun, on the other. Please do not post any of my code nor that of our Members on other Forums without our permission.

set "fileMask=%~1"





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users



How to remove advertisement from MSFN