Jump to content


  • 0
radish

ps extraction path specific name syntax problem

Question

$a = "C:\Program Files (x86)\Google\Chrome\Application\80.0.3987.149\Installer\setup.exe --uninstall --system-level --verbose-logging"
$a -replace '([^\\]*)$'  

Suppose my condition is like this
How do I extract the desired folder name

$b = $a  -replace '([^\\]*)$'  

$b = google
or
$b =chrome
or 
$b = Application 

Share this post


Link to post
Share on other sites

1 answer to this question

Recommended Posts

  • 0
On 4/2/2020 at 7:10 PM, radish said:

$a = "C:\Program Files (x86)\Google\Chrome\Application\80.0.3987.149\Installer\setup.exe --uninstall --system-level --verbose-logging"
$a -replace '([^\\]*)$'  

Suppose my condition is like this
How do I extract the desired folder name

$b = $a  -replace '([^\\]*)$'  

$b = google
or
$b =chrome
or 
$b = Application 

 

This can be solved by taking the folder name


 $a.split('\')[2] -replace '\.\w+$' 

google

 $a.Substring(0,$f.LastIndexOf('.')).split('\')[2] 

google


 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...


×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.