Looking for a batch file to move files "greater than"

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
emchance
Posts: 2
Joined: 02 May 2010 21:43

Looking for a batch file to move files "greater than"

#1 Post by emchance » 02 May 2010 22:04

I have tons of fonts I have saved and collected over time plus a few store-bought CD's worth and need to catalog them all.

I have my base files saved on a second drive and all the files have been converted from short names to true names e.g. BES__.ttf to BlackEnglishScript.ttf.

I need to move these files from one file folder to another and it is easy to do in W.E. except where there is already a file by the exact same name. Then I have to stop and compare and I will overwrite the existing file only if the existing file is smaller in bytes than the file I am moving. That get tedious fast with 1,000's of TTF's and OTF's.

So, I'd like to beg for a script/batch that would move all the files from folder 'A' to folder 'B' and where there is an existing file of the same name it would get overwritten ONLY if the overwriting file is larger/greater than the existing file. If it is smaller it gets skipped and we move on to the next file in the queue. When I am done, any files left in folder 'A' I can safely delete as non-wanted dupes as they are smaller than their existing counterparts.

Thanks.

aGerman
Expert
Posts: 4678
Joined: 22 Jan 2010 18:01
Location: Germany

Re: Looking for a batch file to move files "greater than"

#2 Post by aGerman » 03 May 2010 12:37

"Bigger is better" for the same font - is this a joke?
How ever. Try something like that

Code: Select all

@echo off &setlocal

set "source=D:\your\path"
set "destn=E:\your\path"

pushd "%source%"
for /f "delims=" %%a in ('dir /a-d /b *.ttf *.otf') do (
  set "name=%%~nxa"
  set /a bytes1=%%~za
  call :proc
)
popd
goto :eof

:proc
if not exist "%destn%\%name%" (
  move "%name%" "%destn%\%name%"
  goto :eof
)
pushd "%destn%"
for /f "delims=" %%b in ('dir /a-d /b "%name%"') do set /a bytes2=%%~zb
popd
if %bytes1% gtr %bytes2% (
  move /y "%name%" "%destn%\%name%"
)
goto :eof


Regards
aGerman

emchance
Posts: 2
Joined: 02 May 2010 21:43

Re: Looking for a batch file to move files "greater than"

#3 Post by emchance » 03 May 2010 17:20

Thank you ever so much. You are, indeed, a programming God.
Worked like a champ!!!!!

As to font file size, most times bigger is better.

Over the years I have noticed that some type houses, when selling various CD's, have the same font / typeface on them but on one CD there will be a larger file with a lot more to it. More glyphs, perhaps extra ligatures or more foreign punctuation. Hard to say w/o a serious side-by-side comparison within an editor.

I think they may do that for the market...just a guess. CD's for design guys seem to be far more expensive than the CD's from the same type house sold in the big box-type stores. But the design market gets the the 'extra' and pays for the privilege.

Thanks again.

Post Reply