Topic "Local Directry Change and hold it every month"

Author Message
Axum
[View user's profile]

Joined: 2014-06-21
Posts: 4
Location: ETHIOPIA
How to change local directory of WinScp every month automatically?I know I can change every month using WinScp GUI.I did not register when I posted as a Guest;sorry for the duplication.
If you help me,I say thank you very much because all I have got is only gratitude.
Advertisements
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24555
Location: Prague, Czechia
I'm not sure if I understand. Do you want WinSCP to automatically change its GUI startup directory using some pattern (like C:\files_%MONTH%)?
_________________
Martin Prikryl
Guest




Thank you for your quick response.
My question is I want to change the local directory path of winscp and hold it as default automatically in every month like Local Directory path January with January month, February with February month, March with March month etc.This can be done using GUI environment by changing in Local Directory every month and hold it that directory for one month then I change to anther month when the other month comes etc but I want to do it automatically like using script or others without manually.
Sorry for my English.
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24555
Location: Prague, Czechia
Well, you can write a script that changes respective Windows Registry key to modify the path automatically as you need:

Code:
[HKEY_CURRENT_USER\Software\Martin Prikryl\WinSCP 2\Sessions\<session_name>]
"LocalDirectory"="<path>"

_________________
Martin Prikryl
Axum
[View user's profile]

Joined: 2014-06-21
Posts: 4
Location: ETHIOPIA
Thank you for your time and valuable information.
Will you give me a sample script after I try to do it myself?
Axum
[View user's profile]

Joined: 2014-06-21
Posts: 4
Location: ETHIOPIA
I did it using Powershell tool.I thank you very much.
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24555
Location: Prague, Czechia
Would you mind sharing your script?
_________________
Martin Prikryl
Axum
[View user's profile]

Joined: 2014-06-21
Posts: 4
Location: ETHIOPIA
This is the path I change it and made it prepare for scheduler.But only works for one month.I have set up 12 Powershell batches which is not good as an IT professional and that is why I did not replay you on time.This is the path any way and thank you.

Set-ItemProperty -Path 'Microsoft.PowerShell.Core\Registry::HKEY_CURRENT_USER\Software\Martin Prikryl\WinSCP 2\Sessions\xyz@192.168.13.185\' -name LocalDirectory -value "D:%5Coutgoing%20&%20Incoming%20Files%5Cxyz%5Cxyz%20SETTLEMENT%20FILES%5C2014%5CAug"
LordRegent
[View user's profile]

Joined: 2015-06-18
Posts: 2
Here's a PowerShell script that can be run via Task Scheduler to set a WinSCP session's Local Startup Directory to reference the current year and month. It's equally easy to run this once a month or several times a day, using the Triggers settings in Task Scheduler.

Code:
$newPath="D:\outgoing & Incoming Files\xyz\xyz SETTLEMENT FILES\$(Get-Date -format "yyyy\\MMM")"
$regValue=[uri]::EscapeDataString($newPath)
Set-ItemProperty -Path 'HKCU:\\Software\Martin Prikryl\WinSCP 2\Sessions\xyz@192.168.13.185\' -Name LocalDirectory -Type String -Value $regValue


You should Google for a recent guide to the full list of tokens allowed by the "format" parameter; some examples are at https://technet.microsoft.com/en-us/library/Hh849887.aspx, but beware: significant omissions from that list are "MMM" for the short Month Name and "ddd" for the short Day Name (for those that know them, "format" uses the list M$ popularized with VB and their other Scripting products.)

However, if you're more comfortable with the Unix date formatting tokens, use the "uFormat" parameter instead; see http://ss64.com/bash/date.html#format for details on that list of tokens.

The code is broken up into several commands to enhance understanding and simplify maintenance, but it's technically possible to make this into a one-liner.

A good enhancement would be to move the Session Name into a variable, which would limit maintenance updates to the topmost portion of the script's code; this would also ease copying the script for use with another Session and Folder.
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24555
Location: Prague, Czechia
Thanks for sharing this!
Advertisements

You can post new topics in this forum






Search Site

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