Cmpr_Del.btm need help understanding UDF.....

Apr 2, 2011
1,441
10
54
North Carolina, USA
I am unsure and hence would like some assistance in writing a user-defined function, calling it too, please.

It's attached to this post....

Thank you for your assistance....
 

Attachments

  • Cmpr_Del.btm
    966 bytes · Views: 112

samintz

Scott Mintz
May 20, 2008
1,503
16
Solon, OH, USA
Charles, the code as you've written it is more like a subroutine than a FUNCTION. Subroutines are accessed by GOSUB.

Have you considered downloading the free tool WinMerge? It allows you to compare individual files as well as entire directory trees.

Here is my take on a solution for you:
Cmpr_del.btm:
Code:
setlocal
rem returns 1 if files are identical, 0 otherwise
function IsDuplicate=`%@if[%@crc32[%1]==%@crc32[%2],1,0]`
rem returns a relative path 
function relpath=`%@right[-%@len[%1],%2]`
rem convert relative input paths to full paths
set f1=%@full[%1]
set f2=%@full[%2]
rem iterate over all the files from the source tree
do f in /a:-d /d"%f1" /s *
  rem files are names only in a DO loop. Convert to full path
  set sf=%_cwd\%f
  rem convert the full path into a relative path and prepend the dest
  set df=%[f2]%@relpath[%f1,%sf] 
  rem test for duplicate
  iff exist "%df" .and. %@IsDuplicate["%sf","%df"]==1 then
        echo %f is duplicated in %df
  endiff
enddo
 
May 20, 2008
11,414
99
Syracuse, NY, USA
Or just modify it to use correct subroutine syntax ... something like this (untested, and no doubt needs work)
Code:
global /i /q /h for %fn in (*) if %@exec[gosub samefile%fn %1 %2] == 1 echo %1\%fn is duplicated in %2
QUIT

:samefile [fn root1 root2]
  set name1=%root1\%fn
  set name2=%root2\%fn
  iff %@filedate[%name1] eq %@filedate[%name2] .and. %@filetime[%name1] eq %@filetime[%name2] .and. %@filesize[%name1,b] eq %@filesize[%name2,b] .and.%@crc32[%name1] eq %@crc32[%name2] then
    return 1
  endiff
return 0
 
Similar threads
Thread starter Title Forum Replies Date
Joe Caverly MKLINK and Streams and DEL Support 4
S CMDebug 22 issue with del command Support 1
I Puzzling Behavior of TDRV and DEL Support 2
vefatica File system update after DEL? Support 4
vefatica DEL /R on a SUBST'd drive? Support 1
C Del /W999 2gbFile.ext / latest build / Win7 x64 / MSE / Everything Support 5
nickles WAD del unable to delete files ending in "." Support 18
D del /s /q /f asks Are you sure (Y/N)? Support 7
Steve Pitts WAD Strange output from DEL of a non-existent directory Support 7
C DEL, connected Web folder, report Support 1
R /p when used with DEL Support 1
M A possibly stupid question about the "del" command... Support 7
Peter Murschall DEL /Y prompts always ? Support 3
vefatica Files disappear in Explorer when DEL fails Support 6
S WAD DEL /E suppresses fatal ERROR messages Support 2
nickles WAD del behaves inconsistenly# Support 7
David McClelland Why the prompt to del c:\* Support 7
Steve Pitts Are you sure prompt from DEL command Support 5
Steve Pitts Problem with DEL /S+n Support 11
vefatica DEL /Q not fixed Support 7
vefatica DEL /Q? Support 10
A del /w [minor documentation fix] Support 0
S DEL /L question Support 3
krischik WAD DEL *.htm Support 7
Phileosophos What could be slowing a "del /sxz" command? Support 19
S DEL on FTP site : complaint about missing DESCRIPT.ION Support 1
vefatica del, attributes, et c. Support 0
S SELECT DEL (*D.DLL) - output curious Support 8
T DEL disregards switch when using regular expressions Support 2
S DEL unhides directories Support 9
MickeyF equivalent to TCSTART.btm for TCMD? Support 4
vefatica Console not redrawn in BTM or with multiple commands Support 4
Joe Caverly Embedding an .EXE (or other file) into a .BTM Support 8
Charles S. Roaten Problems with TCSTART.BTM Support 1
P Kill all other instances of tcc from a btm batch file Support 2
C TCC 26 BATCOMP BTM problems? Support 5
B IF command problem in tcexit.btm Support 9
vefatica WAD DIR.BTM? Support 11
vefatica BTM, elevated, console window caption? Support 4
I BTM slower than BAT? Support 14
D btm file command line augments comparing for string or math. Support 12
D check for network tcstart.btm and load if newer Support 3
Craig Fitzgerald Problems using tcstart.btm Support 3
vefatica Installer sets BTM associations wrongly Support 4
O I cannot use links to .btm files Support 5
CWBillow Can't right-click a BTM Support 7
C NE1 have BTM to remove %appdata\JP Software\ etc... Support 0
C interesting TCStarts.btm Support 2
JohnQSmith ALIAS /R in TCSTART.BTM Support 9
Paul Berwanger BTM Bugs Support 2

Similar threads