Topic "Synchronize remote with local and exclude subdirectories"

Author Message
JanneFiH

Guest


I've this directory locally that I'ld like to synchronize with a remote server.(I want my remote server to look like the local dir)

/DIR
-> /A
-> /B
-> /C

I would like to exclude subdirectories within A, B C from being synchronized.
I also have some files in /DIR that I also would like to be excluded from being synchronized. Just files in /A/, /B/ and /C/. I don't want to accidentally delete files or folders on either local or remote.

I don't get the .bat-file to start. Can anyone please check what I'm doing wrong? It doesn't post to the log file.

Code:
    "open ftp://USER:PASSWORD@IP:PORT/ -passive=0" ^
    "cd /DIR/A/" ^
    "lcd C:\A\ ^
    "synchronize remote -delete -nopermissions -transfer=binary -filemask="|*/" * ^
    "exit"

set WINSCP_RESULT=%ERRORLEVEL%
if %WINSCP_RESULT% equ 0 (
  echo Success
) else (
  echo Error
)

exit /b %WINSCP_RESULT%


Thanks in advance!
Advertisements
martin◆
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 27059
Location: Prague, Czechia
You are missing any call to WinSCP:

Code:
winscp.com /command ^
    "open ftp://USER:PASSWORD@IP:PORT/ -passive=0" ^
...


See https://winscp.net/eng/docs/guide_automation
Guest




martin wrote:
You are missing any call to WinSCP:

Code:
winscp.com /command ^
    "open ftp://USER:PASSWORD@IP:PORT/ -passive=0" ^
...


See https://winscp.net/eng/docs/guide_automation


I'm sorry. I censored myself when writing the topic.



Code:
@echo off

"C:\Program Files (x86)\WinSCP\WinSCP.com" ^
  /log="F:\skrivbord\log\WinUPP.log" /ini=nul ^
  /command ^
    "open ftp://USER:PASSWORD@IP:PORT/ -passive=0" ^
    "cd /DIR/A/" ^
    "lcd C:\A\ ^
    "synchronize remote -delete -nopermissions -transfer=binary -filemask="|*/" * ^
    "exit"

set WINSCP_RESULT=%ERRORLEVEL%
if %WINSCP_RESULT% equ 0 (
  echo Success
) else (
  echo Error
)

exit /b %WINSCP_RESULT%
martin◆
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 27059
Location: Prague, Czechia
You are missing some quotes.

Here:
"lcd C:\A\" ^
And here:
"synchronize remote -delete -nopermissions -transfer=binary -filemask=""|*/"" * ^
See https://winscp.net/eng/docs/commandline#syntax

Also make sure that the ^'s are the very last characters on their respective lines (there cannot be any space after them).

Code:
@echo off

"C:\Program Files (x86)\WinSCP\WinSCP.com" ^
  /log="F:\skrivbord\log\WinUPP.log" /ini=nul ^
  /command ^
    "open ftp://USER:PASSWORD@IP:PORT/ -passive=0" ^
    "cd /DIR/A/" ^
    "lcd C:\A\" ^
    "synchronize remote -delete -nopermissions -transfer=binary -filemask=""|*/"" * ^
    "exit"

set WINSCP_RESULT=%ERRORLEVEL%
if %WINSCP_RESULT% equ 0 (
  echo Success
) else (
  echo Error
)

exit /b %WINSCP_RESULT%
JanneFiH

Guest


martin wrote:
You are missing some quotes.

Here:
"lcd C:\A\" ^
And here:
"synchronize remote -delete -nopermissions -transfer=binary -filemask=""|*/"" * ^
See https://winscp.net/eng/docs/commandline#syntax

Also make sure that the ^'s are the very last characters on their respective lines (there cannot be any space after them).

Code:
@echo off

"C:\Program Files (x86)\WinSCP\WinSCP.com" ^
  /log="F:\skrivbord\log\WinUPP.log" /ini=nul ^
  /command ^
    "open ftp://USER:PASSWORD@IP:PORT/ -passive=0" ^
    "cd /DIR/A/" ^
    "lcd C:\A\" ^
    "synchronize remote -delete -nopermissions -transfer=binary -filemask=""|*/"" * ^
    "exit"

set WINSCP_RESULT=%ERRORLEVEL%
if %WINSCP_RESULT% equ 0 (
  echo Success
) else (
  echo Error
)

exit /b %WINSCP_RESULT%




Thank you for your corrections, Martin!

Now I at least receive an error log. It's written in my native language.

Quote:
. 2017-10-27 06:09:47.106 Asking user:
. 2017-10-27 06:09:47.106 Fel uppstod när listning av katalog '*'. ("Fel vid hämtning av fillista för ""*\*.*"".","Systemfel. Kod: 123.","Felaktig syntax för filnamn, katalognamn eller volymetikett")
< 2017-10-27 06:09:47.106 Script: Fel uppstod när listning av katalog '*'.
< 2017-10-27 06:09:47.106 Script: Fel vid hämtning av fillista för "*\*.*".

< 2017-10-27 06:09:47.106 Systemfel. Kod: 123.

< 2017-10-27 06:09:47.106 Felaktig syntax för filnamn, katalognamn eller volymetikett
< 2017-10-27 06:09:47.107 Script: Fel uppstod när listning av katalog '*'.
< 2017-10-27 06:09:47.107 Fel vid hämtning av fillista för "*\*.*".

< 2017-10-27 06:09:47.107 Systemfel. Kod: 123.

< 2017-10-27 06:09:47.107 Felaktig syntax för filnamn, katalognamn eller volymetikett
. 2017-10-27 06:09:47.107 Script: Failed
. 2017-10-27 06:09:47.107 Script: Exit code: 1
. 2017-10-27 06:09:47.107 Kopplar ifrån server


Error code 123. It isn't able to fetch file list for "*\*.*"
Please tell me if you would like further translation to be able to see the problem.
martin◆
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 27059
Location: Prague, Czechia
OK, there's one more missing quote, and the * should not be there:
"synchronize remote -delete -nopermissions -transfer=binary -filemask=""|*/""" ^
JanneFiH

Guest


martin wrote:
OK, there's one more missing quote, and the * should not be there:
"synchronize remote -delete -nopermissions -transfer=binary -filemask=""|*/""" ^


Oh my, Mr Hawkeye himself to notice that! It work's really great now! As always, huge thanks for your help, Martin!
Advertisements

You can post new topics in this forum

Search

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