When editing files on the remote server I see that winscp edits the file in a mostly easy to follow directory of where the file is located on the server. Is there a way to change the temporary path to be more informed about what server this is on? It looks like they are using session id as the directory under temp
IE:
%TEMP%\scp<session id>\<path on server>\
I would like something like
%TEMP%\scp\<remote server>\<username>\<session id>\<path on server>\
notice I moved the session id further down the path
So that I can more easily setup some scripts in notepad++ to open pages up on the correct servers.
Or maybe there is an easy way to get the servername and username from the session id in a script?
-----------------------------------------------------------------------------------------
Update:
Found an option that gives me what I want.
under Options under Preferences under Storage I selected "Append session name to temporary path" and the default names are usually username@servername
which works perfect.
------------------------------------------------------------------------------------------
My script I use it in with documentation on how I use it
' c:\helpers\wrapper.vbs
' Written by Jeff Sadowski to use with Notepad++
' expects argument of form <browser>;<file_location>
' expected to be used from %APPDATA%\Notepad++\shortcuts.xml following is an documented entry followed by an example entry
' <Command name="Launch in <Browser Name> <Key Sequence>>wscript "<Path to this file>" "<commandline browser exe name>;$(FULL_CURRENT_PATH)"</Command>"
' <Command name="Launch in Firefox" Ctrl="yes" Alt="yes" Shift="yes" Key="66">wscript "c:\helpers\wrapper.vbs" "firefox;$(FULL_CURRENT_PATH)"</Command>
' <Command name="Launch in IE" Ctrl="yes" Alt="yes" Shift="yes" Key="73">wscript "c:\helpers\wrapper.vbs" "iexplore;$(FULL_CURRENT_PATH)"</Command>
' <Command name="Launch in Chrome" Ctrl="yes" Alt="yes" Shift="yes" Key="82">wscript "c:\helpers\wrapper.vbs" "chrome;$(FULL_CURRENT_PATH)"</Command>
' <Command name="Launch in Safari" Ctrl="yes" Alt="yes" Shift="yes" Key="88">wscript "c:\helpers\wrapper.vbs" "safari;$(FULL_CURRENT_PATH)"</Command>
' <Command name="Launch in Opera" Ctrl="yes" Alt="yes" Shift="yes" Key="79">wscript "c:\helpers\wrapper.vbs" "opera;$(FULL_CURRENT_PATH)"</Command>
' expects in winscp under Options under Preferences under Storage "Append session name to temporary path"
' and use session names with username@servername syntax (the default names)
'last updated 2014 07 29
'temporary variable to get the browser and file_location from
dim data
'url to send to the web browser
dim url
'directory where winscp writes temporary files
dim tempdir
'Regular Expression
dim RE
'WScript Shell
dim wsh
Set RE = New RegExp
RE.IgnoreCase = True
Set wsh = CreateObject( "WScript.Shell" )
'default temporary directory for winscp with session append on.
tempdir=Replace(wsh.ExpandEnvironmentStrings( "%TEMP%" ),"\","\\") & "\\scp[0-9]*\\.*@.*\\"
'get directory and browser
data=Split(WScript.Arguments(0),";")
'for now set the url to the input directory
url=data(1)
'if the file name ends in php replace %TEMP%/scp<number>/<user>@<server>/<path to root of web server> with <web server address> and replace all \ with /
url=replace_directory("php" ,tempdir & "var\\www\\html" ,"http://<server>" ,url)
url=replace_directory("html",tempdir & "var\\www\\html" ,"http://<server>" ,url)
url=replace_directory("cgi" ,tempdir & "var\\www\\cgi-bin" ,"http://<server>/cgi-bin" ,url)
url=replace_directory("php" ,tempdir & "home\\.*\\public_html","http://<server>/~<user>" ,url)
url=replace_directory("html",tempdir & "home\\.*\\public_html","http://<server>/~<user>" ,url)
url=replace_directory("cgi" ,tempdir & "home\\.*\\cgi-bin" ,"http://<server>/~<user>/cgi-bin",url)
'run the browser with the replaced url according to the rules above
CreateObject("Wscript.Shell").Run data(0)+" """+url+""""
'if the file name ends in <extension> replace <directory> with <url> and replace all \ with / otherwise return data unmodified
Function replace_directory(extension,directory,url,data)
RE.Pattern = directory & ".*" & extension & "$"
If RE.Test(data) Then
RE.Pattern="\<server\>"
If RE.Test(url) Then
RE.Pattern=".*\\([^@]*)@([^\\]*).*"
servername=RE.Replace(data,"$2")
RE.Pattern="\<server\>"
url=RE.Replace(url,servername)
End If
RE.Pattern="\<user\>"
If RE.Test(url) Then
RE.Pattern=".*\\([^@]*)@([^\\]*).*"
username=RE.Replace(data,"$1")
RE.Pattern="\<user\>"
url=RE.Replace(url,username)
End If
RE.Pattern = directory
replace_directory=Replace(Replace(RE.Replace(data,url),"\\","\"),"\","/")
Else
replace_directory=data
End If
End Function