Search code examples
tclpwdgetcwdvmd

Tcl print cwd and use it as string


I was making a small script in tcl for VMD:

mol load psf run_1/structure.psf xtc run_1/postDocking_wrapped.xtc
set final [atomselect top "not (water or ions or resid 1216)" frame last]

$final writepdb last_frame.pdb
puts "finished!"

quit

I wish i could add the folder I'm working in as a string to last_frame.pdb

like: last_frame_A1234.pdb where A1234 is my current folder. When I try:

set path [file dirname [file normalize [info script] ] ]

it just returns a "."

I have also tried:

set path [file [info script]]

but the result is always the "." rather than A1234F.

If I put:

set path [pwd]

it would give me the full path (with the "/") and writepdb does not accept special characters.

Is there any way to just get the cwd? or from pwd access only to the last folder and use it as a string?

Thank you!


Solution

  • Try: set path [file tail [pwd]]