Upload a file to sftp and create the path

Advertisement

renaso
Joined:
Posts:
1
Location:
Italy

Upload a file to sftp and create the path

Hello,
nice to be a new member!

I need to synchronize a local folder with remote SFTP folder.
I have two way to do that and I think the first is the best.

My folder tree have a complete FOLDER in my local PC with inside several paths
FOLDER\2022\1
FOLDER\2022\2
...
FOLDER\2022\12
FOLDER\2023\1
the folder names are YEAR and MONTH and inside year there are only 12 folders as months and inside months several files, .csv files

I think that I've 2 ways to do that:
  1. by create the remote path folder tree based in the actual year actual month. Get the actual date and create path by mkdir create the remote folder if not exist (or also if exist) and send the file one by one per times via put command in that folder.

  2. by synchronizing my whole FOLDER with remote root folder with command synchronize remote.
Each time the script sync everything.

The second is the faster I think and I've tried to do that with below scripts and something went wrong.
option echo off 
option batch on 
option confirm off 
 
# OPEN CONNECTION TO
# I can't put SFTP credential here but I generate the open code via WinSCP generate code.
open sftp://...  
# SET LOCAL FOLDER PATH
lcd D:\Results
 
# SET REMOTE SERVER PATH
cd Test
 
# COMMAND TO SYNC
synchronize remote
 
exit

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
38,408
Location:
Prague, Czechia

Re: Upload a file to sftp and create the path

I'm sorry, but we cannot help you based on just "something went wrong". Do you get any error? Or does the behavior differ from, what you expected? How? Please post session log file.

Reply with quote

Advertisement

You can post new topics in this forum