using a verable in a string with out a space

This topic contains 2 replies, has 2 voices, and was last updated by Profile photo of Nathan W Nathan W 1 year, 7 months ago.

  • Author
  • #33004
    Profile photo of Nathan W
    Nathan W

    This one should be easy and I should be able to find it online but I must not be asking the google machine the right question.
    I need to use a verable as part of a file name nested in another verable.
    Simply put I need to set a verable that points to a file name. And that file name I need to pull its verable from a param passed via the cmd line.
    Looks something like this

    $Filename ="D:\Folder\$a1 File.txt"

    I need to remove the spacein the file name.

    As always Thanks!!!!

  • #33007
    Profile photo of Dave Wyatt
    Dave Wyatt

    You can place the variable name in curly braces to help the parser figure out which part is the variable, and which is the string after it:


    You can also use the subexpression operator, but I prefer the first option instead. You can see why when you look at this code in the ISE; the syntax highlighting is nice and neat with the braced variable names.

  • #33008
    Profile photo of Nathan W
    Nathan W


    Thanks 🙂

You must be logged in to reply to this topic.