Skip to content

ps extraction path specific name syntax problem

Featured Replies

$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 

  • Author
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


 

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...

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.