Jump to content


Sign in to follow this  
radish

ps extraction path specific name syntax problem

Recommended Posts

$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
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
Reply to this topic...

×   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...
Sign in to follow this  

×
×
  • Create New...