NuSphere Forums Forum Index
NuSphere Forums
Reply to topic
Copy information to clipboard (file name, etc.)
Guru master

Joined: 24 Jul 2009
Posts: 698
Reply with quote
I write a lot of documentation and often have to type long framework file name paths, which is tedious.

I wanted a quick way of copying file names or other information to the clipboard. Surprisingly, it wasn't easy. I tried a variety of methods such as various script languages and Windows clip.exe, none of which gave a good result. All either required script files, didn't support copying to the clipboard, prompted for something, or didn't copy to the clipboard in an ideal format so I had to further edit.

I came up with the powershell script which gives a good result:

powershell -NoProfile -Command "& { Add-Type -AssemblyName System.Windows.Forms; [System.Windows.Forms.Clipboard]::SetText('@RelFName@') }"

The @RelFName@ is the relative path and filename, which is exactly what I wanted. There might be other useful PhpED replacement variables.

To make this available on the filename tabs with a right-click I did this:

* Tools > Settings > Integration
* Add Menu and give it a name. I used 'Copy file path to clipboard'.
* Choose execute with Shell and enter the powershell command line
* Further down the options, tick Show this command in File Bar popup
* Click Close

Done! You can now right-click file tabs and copy the name to your clipboard.

The powershell window flashes up. Don't bother trying to stop that happening; you can't. Whilst powershell does support minimized and hidden windows, it always first flashes up the window.
View user's profileFind all posts by plugnplaySend private message
Copy information to clipboard (file name, etc.)
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT - 5 Hours  
Page 1 of 1  

 Reply to topic