copy file different size

Sony Crash bash (psx)
December 4, 2009 at 04:54:59
Specs: Linux/Unix, n/a
I know some command line, but I can't get this simple thing running :
I want to copy one file, to another existing file, but only if the filesize of source and target is different. I don't care about timestamps

I would be happy to use XCOPY, XXCOPY or ROBOCOPY, if only I have a parameter that accepts this. XCOPY is missing out I think, XXCOPY's parameter "help" page is not really helping, but I've found this (but it does not work):

C:\>xxcopy test8.txt test9.txt /BZX

XXCOPY == Freeware == Ver 2.97.9c (c)1995-2009 Pixelab, Inc.

The destination is not a directory

C:\>xxcopy test8.txt test9.txt /BZX /Y

XXCOPY == Freeware == Ver 2.97.9c (c)1995-2009 Pixelab, Inc.

The destination is not a directory

C:\>


See More: copy file different size

Report •


#1
December 4, 2009 at 05:15:51
... post here (< click)


.


.

... Posting is provided "AS IS" with no warranties
http://img515.imageshack.us/img515/...
Grrrr... ....more


Report •

#2
December 4, 2009 at 05:26:53
Cannot create it there, says:
ERROR: Posting on multiple forums
Posting on multiple forums may result in all posts being removed!

Please only post your message on one forum. No reason should exist that your question must be asked on more than one forum.


Report •

#3
December 4, 2009 at 07:13:21
Meh, mods now have the power to move threads. If someone cares enough, it'll get moved.

If the size is changing, then the archive bit should be enabled. If that's the case, something like this should work:

xcopy /m /y a b


Report •

Related Solutions

#4
December 4, 2009 at 08:05:13
Here is something that should help....

@echo off

:Main
for %%A in (%1) do (
  set Size1=%%~zA)

for %%A in (%2) do (
  set Size2=%%~zA)

if %Size1% GTR %Size2% goto Size1Bigger
if %Size1% LSS %Size2% goto Size2Bigger
echo Source and Desination are the same.
goto End

:Size1Bigger
echo Source is bigger.
goto End

:Size2Bigger
echo Destination is bigger.
goto End

:End

You can replace the the echos with your copy commands. The syntax, assuming you used compare.bat for your batch file name, would be....

compare file1.txt file2.txt

My source is....

http://www.dostips.com/DtCodeSnippe...

You could do something like...

@echo off

:Main
for %%A in (%1) do (
  set Size1=%%~zA)

for %%A in (%2) do (
  set Size2=%%~zA)

if %Size1% GTR %Size2% goto Size1Bigger
if %Size1% LSS %Size2% goto Size2Bigger
echo Source and Desination are the same.
goto End

:Size1Bigger
xxcopy %1 %2 /BZX
goto End

:Size2Bigger
xxcopy %2 %1 /BZX
goto End

:End


Report •

#5
December 4, 2009 at 09:08:08
I'll have a look Ace ...
Razor : I don't trust the archive bit ... never have, never will

Report •

#6
December 4, 2009 at 09:34:39
Agreed, the archive bit is used by Hackers to sneak their Trojans into your backups so that when you re-image a computer you will just restore their Trojan. Never use the archive bit if you can avoid it.

Report •

#7
December 4, 2009 at 10:03:37
ace_omega: Agreed, the archive bit is used by Hackers to sneak their Trojans into your backups so that when you re-image a computer you will just restore their Trojan. Never use the archive bit if you can avoid it.
This is the best troll I've seen all year.

Report •

#8
December 4, 2009 at 10:52:19
I know its reaching but the best way to compare files for changes is with a Checksum but even that can be exploited.

Report •

#9
December 4, 2009 at 13:16:15
There's no link between an archive bit and the content of a file, so you don't need to joke around it, it's useless in this context

--------------

Ace, checksumming I thought about, but it's not necessary, since the files I'm looking at are being appended with info, which means that the first whatever bytes are always the same, but some files have newer piece added to it ... making the size different, and also the content (which means also the checksum). But, checking on size should be easier, for COPY commands, than checksum differences. Don't know if either ROBOCOPY or XXCOPY has that built in.


Report •

#10
December 4, 2009 at 13:52:27
Ace, the above comparing-script works fine, thanks

Report •

#11
December 8, 2009 at 14:12:45
"There's no link between an archive bit and the content of a file, so you don't need to joke around it, it's useless in this context"

???

Not sure what you mean. I was talking about replacing a system file like Explorer.exe and resetting its Archive Bit so that the automated backup scripts will see it set and do a backup of this file into your system state backup. This way if the administrator did a system state restore it would just restore my Trojan.

Its a bit of a stretch because Windows will not let your replace a system file from a logged in Windows OS Session (Unless some one was not keeping up on their updates). You would have to have physical access to the box and boot from a Linux CD so that you can replace such a system file and if I had physical access I own your box any ways.


Report •

#12
December 9, 2009 at 02:14:36
Yes, but this thread is not about MS's backup application, and it has not much to do with it. If that tool relies on the Archive attribute, OK.

So, I've figured that /BZX works, but only if param1 of XXCOPY contains (a) wildcard(s), and if param2 is a directory. According to me, it should work with 1 file as well, but it doesn't.


Report •


Ask Question