keepuptodate / Synchronize keeps uploading everything from a directory when a new file is added

Advertisement

Nardog
Joined:
Posts:
3
Location:
Virginia

keepuptodate / Synchronize keeps uploading everything from a directory when a new file is added

I am using keepuptodate to watch 5 directories. When a new file is introduced to one of the directories, it recognizes the change and then starts to upload everything in the directory from Local to Remote despite it already being present in the remote directory.

Script:
@echo off
 
"C:\Program Files (x86)\WinSCP\WinSCP.com" ^
  /log="C:\Program Files (x86)\FTP\WinSCPbatch3.log" /ini=nul ^
  /command ^
    "open ftp://user:pass@ftp.com/" ^
    "cd FTP" ^
    "cd FromCompany" ^
    "lcd C:\FTP\Company\Outbound" ^
    "keepuptodate C:\FTP\Company\Outbound /FTP/FromCompany" ^
    "exit"
 
set WINSCP_RESULT=%ERRORLEVEL%
if %WINSCP_RESULT% equ 0 (
  echo Success
) else (
  echo Error
)
 
exit /b %WINSCP_RESULT%
Within Local Directory C:\FTP\Company\Outbound, there are 5 subdirectories.
I tried using synchronize both but when i ran it, it compared all 5 directories and then tried to reupload every file again. Is there something I am missing?

Thanks for the help!

Reply with quote

Advertisement

Nardog

Re: keepuptodate / Synchronize keeps uploading everything from a directory when a new file is added

Martin, thank you for that resource. It does appear to a timestamp issue between filesystems. Unfortunately, I am not in control of the unix system the files are being uploaded to. Is there a way to compare files by filename and upload any files that the compare does not find instead of using timestamps? This would fix my issue. Otherwise, can you think of anyway around the problem? Really appreciate the help.

Reply with quote

AllAboutSim
Joined:
Posts:
2

Hello,

currently I have also an issue like this when using keepuptodate.

Either in GUI or in a batch file. I want to "keepuptodate"
Local: D:\TEST
Test has 3 subdirectories 1\, 2\ and 3\
Remote: /TEST

Options set: all default

File mask: ; 1/ | */

What I am trying to do:
watch D:\TEST directory but only upload changes in subdirectory 1\

Whatever I do, when I add a file in D:\TEST it will also be uploaded to the server. The file mask does not work (not working in batch file, neither when using the UI)

/TEST ist just for ... testing.

The real remote directory will be the root directory on the server. Because of this I want to only include some directories and exclude all others.

The bat file:
@echo off
set var=%cd%
"P:\WinSCP Portable\WinSCP.com" /command "option batch continue" "option confirm off" "open <some site>" "keepuptodate -filemask=""1/ | */"" "%var%" "/TEST" -delete"
Time passed with bat file testing, reading all faq I could find... multiple hours, file mask not working!

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
41,210
Location:
Prague, Czechia

@AllAboutSim: First of all, I do not understand, why you synchronize parent/root folder, if you want to synchronize only one of its subfolders.
This should do:
keepuptodate C:\local\path\1 /TEST/1 -delete

Anyway, indeed your file mask allows files in the root folder. File and directory masks are separate.
You have to exclude root files like:
./1/ | .\*
See https://winscp.net/eng/docs/file_mask

Reply with quote

AllAboutSim
Joined:
Posts:
2

Hello,

First of all, I do not understand, why you synchronize parent/root folder, if you want to synchronize only one of its subfolders.
Because the directories I need to watch are in the root directory of my webspace. The root directory also contains directories like bin, conf, lib, logs and so on.

I could also write
set var=%cd%
set "Folders=1 2 3"
 
for %%a in (%Folders%) do (
  START "" /min "P:\WinSCP Portable\WinSCP.com" /command "option batch continue" "option confirm off" "open <some url>" "keepuptodate "%var%"\%%a\ "/TEST/%%a/" -delete"
)
But this opens 3 command line windows. I will stick with that.

Because ./1/ | .\* watches the directory named 1 like it should and changes are recognized but no upload is being done.
Change in 'D:\TEST\1' detected. // create file
Change in 'D:\TEST\1' detected. // rename file
Change in 'D:\TEST\1' detected. // delete file
So I just let it open 3 command line windows.

Reply with quote

Advertisement

You can post new topics in this forum