Is there a GUI way to copy a folder's path in MATLAB?
Andrew Mclaughlin
Is there a way to easily copy the name of a folder's full path within MATLAB, from the MATLAB folder window, into a MATLAB script or command window?
Dragging with mouse would be very nice, but I guess it runs cd(). Maybe we can somehow change its behavior?
Or is there any extension/toolbox etc., that can make this easier?
Thanks for any help !
I'm asking for 64-bit Windows (7 and) 8, MATLAB R2015b
41 Answer
Within Matlab, I find the easiest way is just to open a script/function file in that folder, if the folder I'm interested in has such a file. Then in the list of open files, I right click on that file's name, and "Copy Full Path to Clipboard"
Another way is to drag the path to the command window, and that will indeed change the current folder. However, you can then use the back arrow on the address bar to return to your previous directory. And then you've got the text in your command window to copy and paste.
If you're going to be doing this a lot, it's probably better if at all possible to work out an algorithm to do the directory selection that you are doing manually, and program up the bit to obtain directory paths. Or even to rearrange your directories to make it easier for your program to do its work by just using relative paths.
In Windows Explorer, to get the path of the current windows explorer window into the clipboard, just click once in the blank space in the address bar. This will convert the text in there into a path, already selected. Just press Ctrl-C to put this in your clipboard. Then just paste into Matlab (or any other app that's expecting plain text)
5