Need help making a simple file back up button

I could do this in jscript, but it seems like it should be very simple to make a simple button with the copy command.

Situation: I have files in a folder that I want to be copied to another folder (all files and folders in that folder). If the files already exists in the destination folder I wanted it to always overwrite those existing files and folders.

This is my rough guess at how to do it, but I can't find a way to set the source files/source folder

Copy ?how to set source files? TO "lib://Backups/Daily Backup Folder" WHENEXISTS=replace,merge

Or I could do it in jscript, but it seems like that would be more typing. Maybe something like this...

//assume cmd is assigned command object
var folderEnum = DOpus.FSUtil.ReadDir("c:\path\path");
while (!folderEnum.complete) {
          var folderItem = folderEnum.Next();
          copyItem(folderItem, cmd, "c:\backuppath\path");

function copyItem(item, cmd, dest) {
	cmd.Runcommand("Copy WHENEXISTS=replace,merge");

Avoiding scripting, you can either use wildcards to specify the files you want to copy (preferable) or run multiple copy commands and specify one file per line (less good; will not be great in terms of progress dialogs, if the files are large enough for them to appear).

If you want to copy everything in a folder, a wildcard will do that. Or copy the folder itself.

But how do I define that? Do I just type it? everything else seems to need a keyword like "TO" for example.

Copy ?how to set source files/folders? TO "lib://Backups/Daily Backup Folder" WHENEXISTS=replace,merge

Is any of the code I wrote even correct?

is this how I define the source?

Copy "c:\sourcefile" TO "c:\Backups/Backup Folder" WHENEXISTS=replace,merge

Looks correct. There are examples in the manual for most command arguments:

Looking at that, actually, the FILE argument can be given more than one path, which I forgot about. So you could also specify multiple things that way. But if it's just everything in one folder then a simple wildcard will do.

So in that example I don't have to use the word FILE. I can type the directory and the *. does that seem look correct?

Copy "C:\Data Directory\*" TO /desktop

Also, do you think WHENEXISTS=replace,merge is the correct option to use If the files already exist in the destination folder and I want it to always overwrite those existing files and folders?

I doubt you want the files copied to your desktop folder, but otherwise it sounds correct.

The manual describes what WHENEXISTS=replace,merge do if you're in doubt about those.

Well, it was the path in the example in the documentation that you pasted, didn't really see the need to post the names of my personal folders, but I guess I can in the future if you really think it matters.

Yes, I read it several times. Just thought you would have a more intimate knowledge of all the many options that could be used and could give your opinion on what would be best. It's not a big deal, I know you are a busy guy.

Thanks for all your help.

Edit: Nope WHENEXISTS=replace,merge was not a good idea. Seems WHENEXISTS=replace is what I needed.

There are so many options available to us DOpus users that it is hard to keep on top of them all. I find it helps to maintain a test structure for trying out commands that I am not 100% familiar with. Something as simple as C:\Test\Source and C:\Test\Target. Open on either side of a dual lister, populate with test files and folders, and then try whatever commands you want to get to know well.

Are you aware that there is a quick way of trying commands without having to create a button? Simply type > followed by your test command and then press Enter. Very handy.



Thanks, I do use files and folders to test with and I do have a way to test commands with a simple click.

But I should probably create a script that resets all test files and folders to a starting state. I didn't consider that. I have been manually repairing my test structure so far after each test. wasting a lot of time.