Copy selected item as *nix path (Q:\.. > /home/myname/..)
Posted: 08 Jan 2015 19:01
My first generically useful script 
(Posted on my blog: https://aliteralmind.wordpress.com/2015 ... twintonix/ )
Code: Select all
/*
Command to copy the selected item as a *nix path. If no file is selected,
the current-working directory is used (and an extra slash is placed at
the end). If the selected file is not on the configured drive, an error
dialog is presented. Otherwise, the status bar confirms success.
This is intended for when working in a shell to, for instance, an Ubuntu
machine that is connected you Windows machine via SFTP.
LIMITATION: This currently supports only a single SFTP drive.
The Caption and key-command I use in the User menu:
Copy Q:\ path as *nix (Q:\... > /home/jeffy/...) [Ctrl+Alt+P]
*/
//Configuration
/*
The SFTP drive letter. Must be a single character.
*/
$nixDriveLetter = 'Q';
/*
What to replace "$nixDriveLetter:" with. Must not end with a slash.
Such as "Q:" to "/home/jeffy".
*/
$nixDLColonReplacement = "/home/jeffy";
//Go:
//http://www.xyplorer.com/xyfc/viewtopic.php?f=3&t=13161&p=116505#p116505
//Get the selected file or, if none selected, the working directory
$origPath = getpathcomponent(, "path").'\'.getpathcomponent(, "file");
if($origPath UnLikeI "$nixDriveLetter:\*") {
echo "ERROR: This command only valid for files on $nixDriveLetter:\.";
end true;
}
$path = replace($origPath, "\", "/");
$path = replace($path, $nixDriveLetter.":", $nixDLColonReplacement);
$isDir = (exists($origPath) == 2);
if($isDir) {
$path = $path."/";
}
copytext $path;
status "Copied '$path'";