powershell - How can I compress my $path on Windows? -
powershell - How can I compress my $path on Windows? -
windows has 260 character limit path. i've blown way past it, , it's aggravating. i'd find way bypass that.
so far, i've had thought of writing script in powershell path variable, parse it, , set path windows shortpath representations of strings inside.
here's have far:
function get-shortname { begin { $fso = new-object -comobject scripting.filesystemobject } process { if ($_.psiscontainer) {$fso.getfolder($_.fullname).shortname} else {$fso.getfile($_.fullname).shortname} } } function get-shortpath { begin { $fso = new-object -comobject scripting.filesystemobject } process { if ($_.psiscontainer) {$fso.getfolder($_.fullname).shortpath} else {$fso.getfile($_.fullname).shortpath} } }
i'm total beginner powershell, , i'm stumped how parse semicolon delimited list $env:path returns , turn can pass get-shortpath functions. suggestions?
as you've noted, value of $env:path
semicolon-separated list.
to split up, utilize -split
operator:
$paths = $env:path -split ";"
since haven't declared named or positional parameters in functions, you'll have pipe strings them:
@($env:path -split ";") | get-shortname
powershell
Comments
Post a Comment