0

I run a PowerShell script from the context menu on a selected file. But I struggle to find the way to simply get the file name of this file.

The file name selected is 1.mp3 which is inside the directory sound

I managed to extract some information about the selected item such as:

$FolderPath = Get-Location
$FolderName = [IO.Path]::GetFolderName($FolderPath)

I tried to get its file name using things like $File_path = %1 (since regedit use %1 which is suppose to contain the path).

1
  • 1
    Check $Args in your script. See Get-Help about_Automatic_Variables
    – LotPings
    Dec 28, 2018 at 9:51

1 Answer 1

1

$Args is an automatic variable,

Cite from Get-Help about_Automatic_Variables

$Args Contains an array of the undeclared parameters and/or parameter values that are passed to a function, script, or script block. When you create a function, you can declare the parameters by using the param keyword or by adding a comma-separated list of parameters in parentheses after the function name.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .