Add option to mkdir to help with directory already existing
A common need when scripting is to create a directory if it does not exist and to proceed if it already does. However, the scripting interface does not contain a way to check if it exists or to skip creation if it does.
The best work around at the moment appears to be disabling errors before attempting to create the directory:
But this can also cause the script to continue in other error cases, such as a failure due to not having permissions. Another option is to switch to writing code in a separate language interface, but that's an incredibly heavy handed solution for such a simple and common need.
It would be better if mkdir supported continuing when the directory exists out of the box. Something like this, for example:
(The option name could be something different, of course.)
Here are some threads referencing this need:
https://winscp.net/forum/viewtopic.php?t=15867
https://winscp.net/forum/viewtopic.php?t=8336
https://winscp.net/forum/viewtopic.php?t=4580
The best work around at the moment appears to be disabling errors before attempting to create the directory:
option batch continue mkdir /my/remote/dir option batch abort cd /my/remote/dir put ./myfile.txt
But this can also cause the script to continue in other error cases, such as a failure due to not having permissions. Another option is to switch to writing code in a separate language interface, but that's an incredibly heavy handed solution for such a simple and common need.
It would be better if mkdir supported continuing when the directory exists out of the box. Something like this, for example:
mkdir -skipifexists /my/remote/dir cd /my/remote/dir put ./myfile.txt
(The option name could be something different, of course.)
Here are some threads referencing this need:
https://winscp.net/forum/viewtopic.php?t=15867
https://winscp.net/forum/viewtopic.php?t=8336
https://winscp.net/forum/viewtopic.php?t=4580