Topic "when synchronize create remote directory if not exists"

Author Message
unknown
[View user's profile]
Donor
Joined: 2014-04-02
Posts: 4
When scripting, can winscp create remote directory (and its parents directories) if not exists?

e.g. when i need to backup the following folders

local "C:\Users\a\Desktop" -> remote "a\Desktop"
local "C:\Users\b\Desktop" -> remote "b\Desktop"
local "C:\Users\c\Desktop" -> remote "c\Desktop"

my script need to do the following:
mkdir a
cd a
lcd a
synchronize Desktop Desktop
cd ..

.......
Advertisements
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24512
Location: Prague, Czechia
The root destination directory has to exist prior to synchronization. Any absent sub-directories will be created.
_________________
Martin Prikryl
unknown
[View user's profile]
Donor
Joined: 2014-04-02
Posts: 4
prikryl wrote:
The root destination directory has to exist prior to synchronization. Any absent sub-directories will be created.


but when scripting, it is tedious and error-prone, to repeat: mkdir->cd->mkdir->cd->...->synchronize->go to parent directory->..->go to parent directory.

Besides, there is no formal documentation for cd to parent directory.
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24512
Location: Prague, Czechia
Not sure, if I understand you. As I wrote, subdirectories are created.

So if you execute: synchronize remote c:\web /home/username/httpdocs only the httpdocs needs to exist.
If there's c:\web\images, but not /home/username/httpdocs/images, the images subfolder is created.
Guest




prikryl wrote:
Not sure, if I understand you. As I wrote, subdirectories are created.

So if you execute: synchronize remote c:\web /home/username/httpdocs only the httpdocs needs to exist.
If there's c:\web\images, but not /home/username/httpdocs/images, the images subfolder is created.


Sometimes there is a need to sync a few subfolders only

e.g. Desktop,Documents,Music insides user profile directory, as there is too many garbage insides
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24512
Location: Prague, Czechia
Quote:
Sometimes there is a need to sync a few subfolders only

e.g. Desktop,Documents,Music insides user profile directory, as there is too many garbage insides

How's that related?
_________________
Martin Prikryl
adam
[View user's profile]

Joined: 2014-07-21
Posts: 5
prikryl wrote:
Not sure, if I understand you. As I wrote, subdirectories are created.

So if you execute: synchronize remote c:\web /home/username/httpdocs only the httpdocs needs to exist.
If there's c:\web\images, but not /home/username/httpdocs/images, the images subfolder is created.


I believe OP desires functionality same as GNU coreutil's "cp --parents"

https://www.gnu.org/software/coreutils/manual/html_node/cp-invocation.html
Code:
‘--parents’
Form the name of each destination file by appending to the target directory a slash and the specified name of the source file. The last argument given to cp must be the name of an existing directory. For example, the command:
          cp --parents a/b/c existing_dir
copies the file a/b/c to existing_dir/a/b/c, creating any missing intermediate directories.


Using your example,

Code:

mkdir c:\web; cd c:\web
synchronize local -parents c:\web /home/username/httpdocs
if c:\web\home\username\httpdocs does not exist, then
  mkdir home; mkdir home\username; mkdir home\username\httpdocs;
  get /home/username/httpdocs/* c:\web\home\username\httpdocs
else
  synchronize c:\web\home\username\httpdocs /home/username/httpdocs


It is similar to my request of creating empty directories, http://winscp.net/forum/viewtopic.php?t=14131 only implemented at the scripting level. Essentially it allows for retaining a directory structure without having to transfer all parent sibling objects. My desire for this at the GUI level is a user can slowly recreate a remote directory structure on their local drive slowly, as needed. Which makes it easier to synchronize if they have already grabbed a few sub-folders of a target sync directory.

I can see this being a useful enhancement.
As an initial progression to get this functionality included, perhaps a workable goal would be a mkdir -parents option?

https://www.gnu.org/software/coreutils/manual/html_node/mkdir-invocation.html

Thank you for all your hard work on this program!
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24512
Location: Prague, Czechia
Thanks for the explanation. Will consider it.
_________________
Martin Prikryl
Advertisements

You can post new topics in this forum






Search Site

What is WinSCP?

It is award-winning SFTP client, SCP client, FTPS client and FTP client integrated into one software program for file transfer to FTP server or secure SFTP server. [More]

And it's free!

Donate

About donations

$9   $19   $49   $99

About donations

Recommend

WinSCP Privacy Policy

WinSCP License