0

how can split the name in tcl?

NEW in ARCHIVE XVID/J/JURASSIC.WORLD 

path is not always the same, it may also be so

/XVID-BOXSET/007.A.VIEW.TO.A.KILL 

and set this as variable, one variable set the name and one the path.

I need the following variables:

Name example : JURASSIC.WORLD bzw 007.A.VIEW.TO.A.KILL

Path example : XVID/J/ bzw /XVID-BOXSET/

Donal Fellows
  • 133,037
  • 18
  • 149
  • 215

1 Answers1

3
set pn [lindex {NEW in ARCHIVE XVID/J/JURASSIC.WORLD} 3]
# -> XVID/J/JURASSIC.WORLD
set path [file dirname $pn]
# -> XVID/J
set name [file tail $pn]
# -> JURASSIC.WORLD
Peter Lewerin
  • 13,140
  • 1
  • 24
  • 27
  • @now, the thing to do now is accept this answer: https://stackoverflow.com/help/someone-answers – glenn jackman Feb 21 '16 at 15:38
  • Well strictly speaking, `lindex` should not be used. The path in the first case is `NEW in ARCHIVE XVID/J` (it's just a directory name with spaces in it). – Jerry Feb 22 '16 at 07:51
  • 2
    @Jerry: not according to the path examples in the question. – Peter Lewerin Feb 22 '16 at 16:44
  • @PeterLewerin Ah! I agree then. Maybe OP forgot to add it in the desired path. Sadly, he doesn't appear to be coming back soon. – Jerry Feb 23 '16 at 05:55