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

J. Does
  • 149

1 Answers1

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.

LotPings
  • 7,391