From: Mayne, Christopher G (cmayne2_at_illinois.edu)
Date: Fri Dec 05 2014 - 09:05:46 CST

Tcl has functions for handling filenames. See:
https://www.tcl.tk/man/tcl8.6/TclCmd/file.htm

It's not completely clear what you are looking for, but something like:
> file dirname [lindex [molinfo top get filename] 0]
would hand you back "test" in your case

If you need a full path, I direct you to "file normalize" command, which I've found very handy in certain situations.
> file dirname [file normalize [lindex [molinfo top get filename] 0]]
would hand you back /path/to/test

The real benefit of using the build-in commands is that (most of them) work cross platform, which is important when MacOS and Linux use "/" and Windows use "\" separators.

Regards,
Christopher Mayne

On Dec 4, 2014, at 10:46 PM, Tristan Croll wrote:

If you’re only doing this for one trajectory at a time, why not simply change to the working directory in TkConsole, and use “./” for the directory in your script?

From: owner-vmd-l_at_ks.uiuc.edu<mailto:owner-vmd-l_at_ks.uiuc.edu> [mailto:owner-vmd-l_at_ks.uiuc.edu] On Behalf Of Mohammad Khalkhali
Sent: Friday, 5 December 2014 1:04 PM
To: Cun Zhang
Cc: vmd-l_at_ks.uiuc.edu<mailto:vmd-l_at_ks.uiuc.edu>
Subject: Re: vmd-l: How can I get the path of the TOP molecule in the tcl console?

Exactly! What I need is something that just show "test/". I need the path of the directory of the top file. There should be some easy way to do this instead of manipulating "molinfo top get filename" output.

On Thu, Dec 4, 2014 at 7:58 PM, Cun Zhang <apzc2529_at_gmail.com<mailto:apzc2529_at_gmail.com>> wrote:
Here is my output:
cunzhang_at_Debian:~$ vmd test/test.pdb test/test.xtc
>molinfo top get filename
{test/test.pdb test/test.xtc}

BTW: Please cc to vmd-l_at_ks.uiuc.edu<mailto:vmd-l_at_ks.uiuc.edu> when you reply.

On Fri, Dec 5, 2014 at 10:43 AM, Mohammad Khalkhali <khalkhal_at_ualberta.ca<mailto:khalkhal_at_ualberta.ca>> wrote:
Hi Cun,

I tried this. This gives the file name what i need is the path of the file.

Cheers!
MK

On Thu, Dec 4, 2014 at 7:20 PM, Cun Zhang <apzc2529_at_gmail.com<mailto:apzc2529_at_gmail.com>> wrote:
Try command "molinfo top get filename"

On Fri, Dec 5, 2014 at 9:25 AM, Mohammad Khalkhali <khalkhal_at_ualberta.ca<mailto:khalkhal_at_ualberta.ca>> wrote:
Dear VMD community:

I wonder if anyone knows how how I can get the path of a loaded trajectory in the TCL console. I have a tcl code which changes some of atoms' properties in the loaded trajectory dynamically and then I used these properties to color my molecules. This code reads a data file which is in the same directory the trajectory file directory. I have to change the path in my tcl code manually every time I load a new trajectory file. If I can get the path of TOP molecule somehow, I won't have to change the path of the data file each time. I would appreciate it if you would help me with this.

Cheer!
MK.

--
Please consider the environment before printing this email
Mohammad Khalkhali (MK)
PhD Candidate
Department of Chemical and Materials Engineering
University of Alberta
11421 - Saskatchewan Drive
The National Institute for Nanotechnology (NINT) Building
Edmonton, AB T6G 2M9
Office Number: 5-08
Tel: (780) 492-8775<tel:%28780%29%20492-8775>
khalkhal_at_ualberta.ca<mailto:khalkhal_at_ualberta.ca>
[https://static.licdn.com/scds/common/u/img/webpromo/btn_profile_greytxt_80x15.png]<https://www.linkedin.com/pub/mohammad-khalkhali/48/514/656>
--
========================================
Cun Zhang
Ph.D. Candidate
LNM,Institute of Mechanics
Chinese Academy of Sciences
Beijing, 100190, China
Tel:86-10-82544204
========================================
--
Please consider the environment before printing this email
Mohammad Khalkhali (MK)
PhD Candidate
Department of Chemical and Materials Engineering
University of Alberta
11421 - Saskatchewan Drive
The National Institute for Nanotechnology (NINT) Building
Edmonton, AB T6G 2M9
Office Number: 5-08
Tel: (780) 492-8775<tel:%28780%29%20492-8775>
khalkhal_at_ualberta.ca<mailto:khalkhal_at_ualberta.ca>
[https://static.licdn.com/scds/common/u/img/webpromo/btn_profile_greytxt_80x15.png]<https://www.linkedin.com/pub/mohammad-khalkhali/48/514/656>
--
========================================
Cun Zhang
Ph.D. Candidate
LNM,Institute of Mechanics
Chinese Academy of Sciences
Beijing, 100190, China
Tel:86-10-82544204
========================================
--
Please consider the environment before printing this email
Mohammad Khalkhali (MK)
PhD Candidate
Department of Chemical and Materials Engineering
University of Alberta
11421 - Saskatchewan Drive
The National Institute for Nanotechnology (NINT) Building
Edmonton, AB T6G 2M9
Office Number: 5-08
Tel: (780) 492-8775
khalkhal_at_ualberta.ca<mailto:khalkhal_at_ualberta.ca>
<https://www.linkedin.com/pub/mohammad-khalkhali/48/514/656>