Synchronize script

Don't know if possible, so I ask it here.

I would like to synchro between 2 machines often, but due to space limitation in one of them is necessary to synchro only some files and not others.

The question is:

How can I automate a synchro process through many folders (not necessary in the same tree) and using several filters?

I imagine some solution based on a dopus "script" through dopus commands, but have no idea on this...

Any suggestion?

I do not think you are going to like this answer, but you asked the question, so here goes.

With no matching tree pattern, it's too ambiguous for a standard DOpus synchronization. And because you do not want all files synched between the two machines, just "some files", the only way I can think of to do this would be to write a script that would use an inclusion list which defines exactly which files in which folders in one machine get synched to what folders in the other machine.

What I am about to suggest is crude and would have to be refined but the basic idea is this (requires Windows NT or higher).

First create a simple text file that has two entries on each line. The first entry being the first file to be synched in the first machine, with the second entry being where it should be copied to in the second machine. Continue building your list until you have all desired files listed. Then you'll need to repeat the process in reverse. In its most simplistic form the contents of inclusion list file might look something like this:

"C:\test folder\Source\fil1.txt"?"D:\dir 1\dir2"
"C:\images\mine*.jpg"?"D:\dir 1\images"

Note 2 things about the above. Each path is enclosed by double quotes and there's a ? between the source and destination on each line. That ? is a delimiter, I chose it because it's not a legal character in a file name therefore it serves as a way for the following script to identify which is the source and which is the destination.

:: begin batch file script
@echo off
for /f "tokens=1,2 delims=?" %%a in ('ty^
pe "C:\Mine\cmd\list.txt"') do (
dopusrt /cmd copy file=%%a TO=%%b)
:: end batch file script

Paste the above script into a new text file and save it where you want giving it a file name that ends with .bat or .cmd

Note in my script example the "C:\Mine\cmd\list.txt" represents the inclusion file previously set up.

Finally set up a DOpus button to run the batch file you just saved and if you did everything right, it'll copy the specified files from each machine to the other putting each in the correct location. Due to the complexity of this I did not futher refine the dopusrt copy command to deal with overwriting existing files, I just used the basic copy command as a starting point.

Now aren't you glad you asked? :smiley:

JohnZeman,

Many thanks for your answer :slight_smile: !
Really, I was expecting something like that due to the no matching tree pattern.
I don't mind wasting half a day typing the script if afterwards is going to save me much more time...

But, how could it be redefined using filters?

For example, lets say that in the source folder we have several files of several sizes, but we want only to copy the newer one and within this set, not those weighting more than x MBytes to the destination (it may appear strange, but if you think it is common case in real life).

You may be able to filter by the Location column, although I'm not sure this works with the Sync tool so check the results before relying on it...

[quote]
But, how could it be redefined using filters?

For example, lets say that in the source folder we have several files of several sizes, but we want only to copy the newer one and within this set, not those weighting more than x MBytes to the destination (it may appear strange, but if you think it is common case in real life).[/quote]

I was out of town for awhile, sorry for the slow reply.

First off FWIW I use the xxcopy command line file manager for projects like this, it's made for specialized copying tasks. But that doesn't mean DOpus can't do it, it just takes a little more effort.

You can start with my last template and build into it, DOpus filtering. You'll want to create/test/save your DOpus filter first. For example below is a screenshot (I hope I have never tried to post a screenshot here before) of a simple filter that has 2 criteria. It will only copy files that are less than 100 bytes in size, plus the last modified date must be within the past day. I saved that filter giving it a name of "today and small"

Now to use that filter in the above script change your script from what I posted last time (which was this):

:: begin batch file script
@echo off
for /f "tokens=1,2 delims=?" %%a in ('ty^
pe "C:\Mine\cmd\list.txt"') do (
dopusrt /cmd copy file=%%a TO=%%b)
:: end batch file script

To this:

:: begin batch file script
@echo off
for /f "tokens=1,2 delims=?" %%a in ('ty^
pe "C:\Mine\cmd\list.txt"') do (
dopusrt /cmd copy file=%%a T^
O=%%b filter="today and small.flt")
:: end batch file script

Run the script via a button or just double click on the script file name from DOpus and away you'll go.

Many thankx! :slight_smile:

Just give me some time to try it out and I will let you know!

Hi!

I'm working around this script and am currently dealing with when happens when files already exist and so on.

But, don't know how to delete files that exist in the destination but do not in the source, i.e. the typical "delete files from destination that don't exist in the source" switch in the synchro diopus dialog... :frowning:

I haven't read through this whole post so I hope I don't interject un-usable info - but depending on how you're doing things, maybe you can use something like this series of commands:[code][b]> Select SOURCETODEST

Set STATE=DEST
Select INVERT
Delete[/b][/code]

Artema in addition to what Steje suggested you can use the synchronize utility panel to do this after the script has been run. However I have the feeling you are trying to do this within the script. If so then I suspect you're pushing the limit of what DOpus can do without an internal scripting language to work with.

But we can still do it with DOpus and our external script. Picking up where I left off last time change this script:

:: begin batch file script
@echo off
for /f "tokens=1,2 delims=?" %%a in ('ty^
pe "C:\Mine\cmd\list.txt"') do (
dopusrt /cmd copy file=%%a T^
O=%%b filter="today and small.flt")
:: end batch file script

To this:

:: begin batch file script @echo off for /f "tokens=1,2 delims=?" %%a in ('ty^ pe "C:\Mine\cmd\list.txt"') do ( cls dopusrt /cmd copy file=%%a T^ O=%%b filter="today and small.flt" dopusrt /cmd Go "%%~dpa" DUALPATH=%%b dopusrt /cmd Set UTILITY=Sync,On echo Switch to DOpus and Sync Files then pause ) :: end batch file script

Bear in mind the script pauses each time the source and destination changes so you can manually synchronize the current source and destination before continuing.

Hi, and thanks again.

Yes, what am I trying to do is synchro through a script, in such a way that I do not have to tap into every dir and then push the synchro function.

So, this is the only way when dealing with file that should be deleted, isn't it?

I've tested your new script, and it propmts every time for each file. Also, as I use this nomenclature:

"G:\Tests\sincro."?"\compaq\c$\sincro"

(note the ".") cos otherway it will copy the whole "sincro" source folder to a new "sincro" destination folder, when dopus opens in dual to synchro, the source is not he source itself, but its parent folder, and ask for every file inside.

So, as I see it, maybe it would be better to load the dual lister and not to ask for every file, because one would like to push the compare button first and then decide basing upon the results.

Maybe with this:

rem @echo off
for /f "tokens=1,2 delims=?" %%a in (C:\Mine\cmd\list.txt) do (
cls
dopusrt /cmd Go "%%~dpa" DUALPATH=%%b
dopusrt /cmd Set UTILITY=Sync,On
echo Switch to DOpus and Sync Files then
pause
)

where list.txt:

"G:\Tests\sincro"?"\compaq\c$\sincro"
(without the ".")

Is it possible to open the dual in horizontal mode instead of vertical?

I forgot:

As there are some paths that must be identical to the source, I must update and/or delete all files before copying. This is going to be done in an ("synchroAll.bat" ) another script.

How should I use the delete command to delete everything in the listed folders and no to use the bin? I'm afraid of doing something wrong and deleting the unapropiate files...

This is the end!

After some thinking about pros and cons of deleting, updating, etc, I found a compromise solution for all of them.

Now I use the script only for dopus to load the sync tool on every pair listed in the .txt, and then personally I compare and synchronize depending upon the circumstances.

There's no other way. As U said what I was trying to do is beyond what dopus automatization can do.

This way I still save time, so for the case is a good solution.

Thanx Steje and specially Zeman for your accurate explanations.

C'u next chapter! :smiley:

I am working out of town a lot right now so I have not been able to check in as often as I would like to. Which is why it took me a few days to respond to this.

I am not exactly sure what you are asking me, but as you've found out combining a GUI program like DOpus with command line scripts can sometimes be a bit of an adventure. So as a rule I tend to use a command line file manager with command line scripts and use DOpus commands from within DOpus. They can be mixed as we're doing here but sometimes we just have to do things in a certain way to achieve the desired results. Not sure if that made any sense but then again I never understood the question LOL

Yes. Just add this line to the script:

dopusrt /cmd Set DUAL=Horiz

So the script becomes:

@echo off for /f "tokens=1,2 delims=?" %%a i^ n (C:\Mine\cmd\list.txt) do ( cls dopusrt /cmd Set DUAL=Horiz dopusrt /cmd Set UTILITY=Sync,On dopusrt /cmd Go "%%~dpa" DUALPATH=%%b echo Switch to DOpus and Sync Files then pause )

I am not sure I understand this question either but if you want to force DOpus to NOT delete using the Windows Recycle Bin, then add the NORECYCLE argument to a delete command button. For example:

Delete NORECYCLE

[quote]his is the end!

After some thinking about pros and cons of deleting, updating, etc, I found a compromise solution for all of them.

Now I use the script only for dopus to load the sync tool on every pair listed in the .txt, and then personally I compare and synchronize depending upon the circumstances.

There's no other way. As U said what I was trying to do is beyond what dopus automatization can do.

This way I still save time, so for the case is a good solution.

Thanx Steje and specially Zeman for your accurate explanations.

C'u next chapter![/quote]

Whoops! I did not see this until I posted my last message. Glad you figured things out artema.