XYplorer script for copying path of selected file as *nix

My first generically-useful XYplorer script.

I’ve found a real niche for using XY-scripts, for things that are *only* useful on Windows. I wrote a substantial script for Sublime Text, but realized that, since Sublime can run on Windows, Mac, and *nix, they should be written in Jakarta Ant instead.

(XYplorer is *the* best Windows Explorer replacement, and you should get it now.)

   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]
   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";

      //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'";

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s