Copy to FTP, create folder if necessary?

I can't figure out how to get this basic behavior to work:
Copy selected file to FTP site, subdirectory based on the folder name, which may or may not already exist.

My current script:

@set dirname {sourcepath$|nopath|noterm|escwild}
@set dirpath Audio Books//{$dirname}
@set ftpsite @Phone/Phone_WiFi
//@set ftpsite ftp://user:password@ip:port
@set ftppath {$ftpsite}//{$dirpath}

MSG "{$ftppath}"
CreateFolder "{$ftppath}"
MSG "Got past CreateFolder?"

Copy TO="{$ftppath}"
MSG "Complete?"

($ftppath then may contain a string like "@Phone/Phone_WiFi//Audio Books//Test//")

If the dir on the server doesn't exist, the above works.
If it does, I get the error message

An error occurred creating folder 'Test':
550 /Audio Books/Test: already exists.

Commenting out the folder creation of course flips the problem, such that the COPY fails when the dir DOESN'T already exist.


  1. Is there a way to tell DOpus to implicitly create the path dirs if they don't already exist when copying to FTP?
  2. Is there a way to tell DOpus to please ignore all errors or error 550(?) for the CreateFolder call?
  3. Is there a different approach I should be using?

Thank you all :blush:

Good news: I'm stupid! :sweat_smile:
COPY has an argument called CREATEFOLDER, which does what I wanted.
Instead of using TO, use it like Copy CREATEFOLDER="{$ftppath}": It will not throw an error if the directory already exists.

Still posting for posterity and because of question 2

1 Like