Topic "How do I create a unique filename when -put- for each file picked up."

Author Message
cougarmutt

Guest


The below script overwrite if it picks up multiple files
I need for it to create a unique filename for each file picked up.
the %RANDOM% does not work


option echo off
option batch on
option confirm off
open sftp://<USERNAME>:<PASSWORD>@<SFTP SERVER URL>

#GRAB SYSCO FILES AND MOVE TO THE EDI\SYSCO\ FOLDER ON BLACKSMITH
lcd "C:\Users\ccancilla\Documents\WinSCP\Blacksmith\SYSCO"
cd /EDI/SYSCO/
put -nopermissions -nopreservetime "SYSCO*.txt" SYSCO_867_%TIMESTAMP%.txt

#GRAB USFS FILES AND MOVE TO THE EDI\USFS\ FOLDER ON BLACKSMITH
lcd "C:\Users\ccancilla\Documents\WinSCP\Blacksmith\USFS\"
cd /EDI/USFS/
put -delete -append -nopermissions -preservetime "USFS*.txt" USFS_867_%TIMESTAMP%.txt

exit
martin◆
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 27083
Location: Prague, Czechia
WinSCP does not have a function to generate random file names.

But it's easy to write a PowerShell script with use of WinSCP .NET assembly and its Session.EnumerateRemoteFiles and Session.PutFiles methods and Get-Random PowerShell cmdlet.

https://winscp.net/eng/docs/library_powershell
https://winscp.net/eng/docs/library_session_enumerateremotefiles
https://winscp.net/eng/docs/library_session_putfiles
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