Conditionally MOVE/COPY files on the basis of size

Jun 7, 2008
121
0
Hi

I have 2 different directories such that some files exist in both.

For the files that exist in both, if the file is larger in the 2nd directory, can I conditionally COPY/MOVE to the 1st directory?
I should wind up with 1st directory containing its files + the larger of the two files where the same filename.

I have been looking at for %a but not getting far.

Thanks

Stephen Howe
 
May 20, 2008
3,515
4
Elkridge, MD, USA
| I have 2 different directories such that some files exist in both.
|
| For the files that exist in both, if the file is larger in the 2nd
| directory, can I conditionally COPY/MOVE to the 1st directory? I
| should wind up with 1st directory containing its files + the larger
| of the two files where the same filename.
|
| I have been looking at for %a but not getting far.

No simple way. Try this (UNTESTED!!!):

pushd DIR2
do f in *
if isfile dir1\%f if %@filesize[dir1\%f] LT %@filesize[%f] copy %f dir1\%f
enddo
popd

If there may exist filenames that need to be quoted insert the command below
after DO:
set f=%@quote[%f]

You need to play with COPY options to achieve your goals about automatic
overwriting.
--
HTH, Steve
 
Similar threads
Thread starter Title Forum Replies Date
C question re: Move Support 3
samintz MOVE and Prompt on overwrite Support 3
M MOVE does not behaves like intended (on failure) Support 1
kb6ojs Make /G parameter persistent in COPY/MOVE command? Support 4
F Regexes in REN/MOVE/… commands seem to not work at all Support 3
T How to? Off screen move? Support 3
fpefpe Documentation copy/move using /c or /u Support 2
W Recursive move aborts early Support 2
C b21 MOVE /B Support 8
D How move cursor out of popup edit control after no match? Support 14
nickles Move takecommand.18.0.key location to installation directory Support 4
J junction copy/move handling Support 6
J WAD move /s regression from tcc15 Support 5
C move /F Support 4
vefatica MOVE anomaly Support 8
C Move /s sorce target Support 13
Stefano Piccardi b32 move /Q writes message Support 1
C How to? MOVE and handling out of space Support 2
Joe Caverly How to? Move Window Between Monitors Support 6
S How to? Move files older than one year Support 9
fpefpe move /g Support 4
C Move /MD not always working Support 1
C Move question with Encrypted file... Support 6
W /g option (%) on MOVE cmd appears broken TCC 14.03.57 x64 Support 8
G Fixed MOVE truncates files Support 9
C MOVE making empty destinatation sub-folders Support 10
thedave Move files, inherit permissions Support 14
A Discrepancy in handling of "can't copy or move file to itself" Support 4
A expected behavior of move /sx Support 14
S MOVE from FTP directory to another FTP directory - bug?? Support 2
J directory tree - move or copy Support 3
D MOVE Help typo Support 3
D Suggest Help mention /n no effect in move /n Dir1 Dir2 Support 0
D Move /v to DVD fails but files identical Support 4
S MOVE to different drive Support 3
Joe Caverly Move Buttons Between Tabbed Toolbars Support 2
S Another 4NT 8.02 vs TCC 9.02 diff - MOVE command Support 3
S MOVE command over FTP with 4NT 5.00U Support 0
C Copy (sys) error Support 3
Alpengreis Fixed Crash after copy dialog with big TCC.exception.log Support 5
vefatica Copy/Paste anomaly Support 4
D Documentation Typo in COPY help Support 0
samintz COPY fails to copy from \\wsl$ Support 20
D Differences between TCC and CMD with COPY /b Support 4
fpefpe copy /u and timestamps Support 4
M Strange error messages from TCC in FTP copy Support 7
G TCMD crash when copy Support 3
Alpengreis How to? Copy DIRs with attributes ... Support 4
E Text copy bug Support 1
Alpengreis [TCMD v25.00.24] Problem with copy and paste and the # char via mouse in TCC Support 6

Similar threads