• Skip to main content
  • Skip to search
  • Skip to footer
Cadence Home
  • This search text may be transcribed, used, stored, or accessed by our third-party service providers per our Cookie Policy and Privacy Policy.

  1. Community Forums
  2. Custom IC SKILL
  3. How to get the filename from the filepath

Stats

  • Locked Locked
  • Replies 5
  • Subscribers 143
  • Views 10673
  • Members are here 0
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How to get the filename from the filepath

saurabh96
saurabh96 over 3 years ago

How can we get the filename from the filepath?
for eg ---
I have file path -              /xyz/pwd/lie/cadence/test/file1

I want file1 as output from above filepath?

Regards,

  • Cancel
  • AurelBuche
    AurelBuche over 3 years ago

    There you go:

    (defun cst_basename (path "t")
      "Equivalent to Unix basename"
      (let ((base (rindex path "/")))
        (if base (substring base 2) path)))

    Cheers

    Aurélien

    • Cancel
    • Vote Up +1 Vote Down
    • Cancel
  • saurabh96
    saurabh96 over 3 years ago in reply to AurelBuche

    Thanks Aurel...
    Apart from this is there another way using skill commands (parse string , cdr)?

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Andrew Beckett
    Andrew Beckett over 3 years ago in reply to saurabh96

    That is using SKILL commands. You just want yet another way? Not sure why you can't just use Aurélien's suggestion...

    baseName=car(last(parseString(path "/")))

    or:

    basePat=pcreCompile("[^/]*$")
    baseName=pcreExecute(basePat path) && pcreSubstitute(basePat "\\0")

    There are of course many ways of doing this.

    Andrew

    • Cancel
    • Vote Up +1 Vote Down
    • Cancel
  • AurelBuche
    AurelBuche over 3 years ago in reply to Andrew Beckett

    Not sure this is the right place to mention that but if you go with Andrew's second solution, please be careful with pcreSubstitute as it relies on rexMagic switch

    • Cancel
    • Vote Up +1 Vote Down
    • Cancel
  • Andrew Beckett
    Andrew Beckett over 3 years ago in reply to AurelBuche
    AurelBuche said:
    Not sure this is the right place to mention that but if you go with Andrew's second solution, please be careful with pcreSubstitute as it relies on rexMagic switch

    That's not good. I hadn't realised that and it's poorly documented. I think that's rather dangerous (I dislike global switches with a passion). I'll take that up with R&D...

    Andrew

    • Cancel
    • Vote Up +2 Vote Down
    • Cancel

Community Guidelines

The Cadence Design Communities support Cadence users and technologists interacting to exchange ideas, news, technical information, and best practices to solve problems and get the most from Cadence technology. The community is open to everyone, and to provide the most value, we require participants to follow our Community Guidelines that facilitate a quality exchange of ideas and information. By accessing, contributing, using or downloading any materials from the site, you agree to be bound by the full Community Guidelines.

© 2025 Cadence Design Systems, Inc. All Rights Reserved.

  • Terms of Use
  • Privacy
  • Cookie Policy
  • US Trademarks
  • Do Not Sell or Share My Personal Information