A More Efficient File upload script using WIldcard/Switches?

Advertisement

turner14466@gmail.com
Joined:
Posts:
1
Location:
UK

A More Efficient File upload script using WIldcard/Switches?

From a WinSCP newbie: I have an existing script (see snippet below) that auto-uploads .CSV files from 5 diff. local subdirs off the PORT dir to an identical dir-subdir set-up on the server.

Existing (Inefficient) Script Code Snippet:
# -------------------------------------------------- PORT dir
lcd C:\web\MEF_BATCH\OUT\csv_scen\PORT\cen
cd /risknz.mef-uk.com/csv_scen/sf_2023Q1/PORT/cen
put *.CSV
lcd C:\web\MEF_BATCH\OUT\csv_scen\PORT\sf1
cd /risknz.mef-uk.com/csv_scen/sf_2023Q1/PORT/sf1
put *.CSV
lcd C:\web\MEF_BATCH\OUT\csv_scen\PORT\sf2
cd /risknz.mef-uk.com/csv_scen/sf_2023Q1/PORT/sf2
put *.CSV
lcd C:\web\MEF_BATCH\OUT\csv_scen\PORT\sf3
cd /risknz.mef-uk.com/csv_scen/sf_2023Q1/PORT/sf3
put *.CSV
lcd C:\web\MEF_BATCH\OUT\csv_scen\PORT\sf4
cd /risknz.mef-uk.com/csv_scen/sf_2023Q1/PORT/sf4
put *.CSV

Q. Is there a more efficient way to structure the code (snippet) below? – as I have about 100 such dir uploads like PORT to perform eg could the code snippet be reduced to only 3 lines with a smart use of wildcards & switches etc??? From my reading of docs, suspect the answer maybe "no" (?) but maybe I missed something.
lcd C:\web\MEF_BATCH\OUT\csv_scen\[DIR-Wildcard or Switch]\[SUBDIR-Wildcard or Switch]
cd /risknz.mef-uk.com/csv_scen/sf_2023Q1/[DIR-Wildcard or Switch]/[SUBDIR-Wildcard or Switch]
put *.CSV

Reply with quote E-mail

Advertisement

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

Re: A More Efficient File upload script using WIldcard/Switches?

No. But you can reduce the repetition like this:
lcd C:\web\MEF_BATCH\OUT\csv_scen\PORT
cd /risknz.mef-uk.com/csv_scen/sf_2023Q1/PORT
 
put cen\*.CSV cen/
put sf1\*.CSV sf1/
put sf2\*.CSV sf2/
...

Or use WinSCP .NET assembly from PowerShell (or other) script for more flexibility.

Reply with quote

Advertisement

You can post new topics in this forum