Synchronize -filemask and exclude empty directories (command line)

Advertisement

ttop
Joined:
Posts:
4
Location:
Ireland

Synchronize -filemask and exclude empty directories (command line)

Hi,
I realise the below script is not correct as I have a few queries about how to move forward.

--I am writing a script for file transfer synchronisation
--I wish to sync my local directory with the remote directory but I don't want all the remote directory empty folders?
--I also only want the most recent files available from the non-empty directories of the Remote end sync's into me local end?
--I will schedule this .bat file once complete ti run every 15minutes
--The below synchronisation still downloads the empty directories?
for /f "tokens=2 delims==" %%a in ('wmic OS Get localdatetime /value') do set "dt=%%a"
set "YY=%dt:~2,2%" & set "YYYY=%dt:~0,4%" & set "MM=%dt:~4,2%" & set "DD=%dt:~6,2%"
set "HH=%dt:~8,2%" & set "Min=%dt:~10,2%" & set "Sec=%dt:~12,2%"
set datestamp=%YYYY%%MM%%DD%
 
set CONN_SFTP_SVR="ftp://user:password!@10.10.10.10 hostkey=* -rawtransfersettings ExcludeEmptyDirectories=1"  
::::::I tried the '-rawtransfersettings ExcludEmptyDirectories=1' here, but I am not sure how to include this?:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
 
set LOCAL_DIR1="D:\A\B\C\D\E\"
set LOCAL_DIR2=""D:\A\B\C\D\A1\"
set LOCAL_DIR3=""D:\A\B\C\D\A2\"
set LOCAL_DIR4=""D:\A\B\C\D\A3\"
 
set REMOTE_DIR1="D:\A\B\C\D\E\"
set REMOTE_DIR2=""D:\A\B\C\D\A1\"
set REMOTE_DIR3=""D:\A\B\C\D\A2\"
set REMOTE_DIR4=""D:\A\B\C\D\A3\"
 
set file_pattern=*%datestamp%*statsfile.xml
 
    
"C:\Program Files (x86)\WinSCP\WinSCP.exe" /xmllog=D:\Logs\!Y!M!D_!T_LOGS.xml 
"/script=D:\LOACTION\TheCommands.txt"

###################################This is my transfer#######################
##A new file arrives on the remote server every 15 minutes and I wan to collect the most recent one. I use >15N but maybe there is a better way?########
 
open %CONN_SFTP_SVR%
option batch abort
######Example of dir 2 only##########
synchronize local -filemask=%file_pattern%>=15N %LOCAL_DIR2% %REMOTE_DIR2%
 
close

Reply with quote

Advertisement

ttop
Joined:
Posts:
4
Location:
Ireland

Synchronize -filemask and exclude empty directories (command line)

Thank you, I realise it is part of the synchronise command, but I could not get it to work that way. See below
open %CONN_SFTP_SVR%
option batch abort
cd %REMOTE_DIR2%
lcd %LOCAL_DIR2%
synchronize -rawtransfersettings ExcludeEmptyDirectories=1 -filemask=*.xml>=15N local
I get the below error
<?xml version="1.0" encoding="UTF-8"?>
<session xmlns="http://winscp.net/schema/session/1.0" name="tleacy@10.147.21.34 -hostkey=*" start="2020-12-11T09:48:14.646Z">
  <failure>
    <message>Unknown option 'ExcludeEmptyDirectories=1'.</message>
  </failure>
</session>
I tried this
open %CONN_SFTP_SVR%
option batch abort
get -rawtransfersettings ExcludeEmptyDirectories=1 -filemask=*.xml>=15N %LOCAL_DIR2% %REMOTE_DIR2%
and I got the below error
<?xml version="1.0" encoding="UTF-8"?>
<session xmlns="http://winscp.net/schema/session/1.0" name="tleacy@10.147.21.34 -hostkey=*" start="2020-12-11T11:26:16.740Z">
  <failure>
    <message>Can't get attributes of file 'ExcludeEmptyDirectories=1'.</message>
    <message>File or folder 'ExcludeEmptyDirectories=1' does not exist.</message>
  </failure>
</session>

Reply with quote

martin
Site Admin
martin avatar

Re: Synchronize -filemask and exclude empty directories (command line)

You are probably using an old version of WinSCP that does not support the -rawtransfersettings. Make sure you use the latest version of WinSCP. If this does not help, please post a session log file, not the XML log.

Reply with quote

Advertisement

Advertisement

You can post new topics in this forum