• 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. Allegro X Scripting - Skill
  3. How to copy a file using SKILL?

Stats

  • Replies 5
  • Subscribers 17
  • Views 12819
  • Members are here 0
More Content

How to copy a file using SKILL?

EvanShultz
EvanShultz over 6 years ago

This is probably a basic question, but for some reason I'm not finding an answer by playing around with code, reading the docs, or Googling. Surely my fault.

How can I copy a file from one location to another? In my case, I want to snag a file from $CDS_SITE that is used for configuration and bring it local.

Not finding a direct SKILL function my belief was I could call to the host OS for a file copy but I don't see that function either. I do not want to simply read the file contents and produce a copy that way, which I can do.

Thanks!

  • Cancel
  • Sign in to reply
Parents
  • eDave
    eDave over 6 years ago

    Try axlOSfileCopy (from memory)

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
Reply
  • eDave
    eDave over 6 years ago

    Try axlOSfileCopy (from memory)

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
Children
  • EvanShultz
    EvanShultz over 6 years ago in reply to eDave

    Yep. That is it. Thank you! I was sure I had seen it at one point but couldn't find it. (And I was mostly looking at the vase SKILL and not Allegro SKILL functions.)

    Another question: can you, or anyone else, give me a working example of this file? The function is returning 'nil' and I'm not sure what I'm doing wrong. I first tried:

    axlOSFileCopy(axlOSSlash(strcat(axlGetVariable("CDS_SITE") "\\pcb\\<file name>.<file extension>")) axlGetVariable("cwd") nil)

    axlGetVariable("cwd") seems to work and gives a fully validated path starting with a drive letter and using single forward slashes. This is the same format I see when I run "set" at the command prompt. Interestingly, axlGetVariable("cdsroot") gives me a drive letter and double backslashes.

    I've tried many variations of the first argument but the function is always returning 'nil' for me. I tried using a drive letter vs UNC path, forward- and backward-slashes, single- and double-slashes...

    I then tried copying between local directories but I still always get 'nil' with no file copied and I tried the same permutations mentioned above. The issue must be me. Ideally I would like to copy from a UNC network path to a local drive on Windows, if that matters. I'm running 17.2 S051. Any tips?

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • DavidJHutchins
    DavidJHutchins over 6 years ago in reply to EvanShultz

    Below is an example from some code I wrote years ago:

    (FileList = list("art_aper.txt" "art_param.txt"))
    foreach(filename FileList
    if( Version < 14.0 then
    if((axlVersion 'isWindows) then
    system(strcat("copy " filename " art"))
    when(PasteList
    system(strcat("copy " filename " outputs"))
    )
    else
    system(strcat("cp " filename " art"))
    when(PasteList
    system(strcat("cp " filename " outputs"))
    )
    )
    else
    (SrcName = strcat(simplifyFilename(".") "/" filename))
    (DestName = strcat(simplifyFilename(".") "/art/" filename))
    unless(axlOSFileCopy(SrcName DestName nil) axlUIConfirm("file copy FAILED"))
    )
    )

    Below is an allegro session implementing your copy example:

    Opening existing design...
    Command > skill axlGetVariable("CDS_SITE")
    "D:/Cadence/SPB_16.6/share/local"
    Command > skill axlGetVariable("cwd")
    "D:/SPB_Data/xxxxx/yyyyyy"
    Command > skill
    Skill > setq file_name "README"
    "README"
    Skill > setq file_ext "txt"
    "txt"
    Skill > setq SrcFile sprintf(nil "%s/pcb/%s.%s" axlGetVariable("CDS_SITE") file_name file_ext)
    "D:/Cadence/SPB_16.6/share/local/pcb/README.txt"
    Skill > setq DestFile sprintf(nil "%s/%s.%s" axlGetVariable("cwd") file_name file_ext)
    "D:/SPB_Data/xxxxx/yyyyyy/README.txt"
    Skill > axlOSFileCopy(SrcFile DestFile nil)
    t
    Skill >

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • EvanShultz
    EvanShultz over 6 years ago in reply to DavidJHutchins

    Ugh. I'm daft. Yes, that works. Thank you!

    For the destination I wasn't giving a file name, only the path. The function example isn't super clear since it doesn't give file extensions, but it was a silly mistake on my part now that I see the problem clearly. (It would be a nice enhancement for the function to retain the source file name if only a folder is given as a destination.)

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
Cadence Guidelines

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