How to retrieve recursively any files with a specific extensions in PowerShell? -
for specific folder, need list files extension .js if nested in subfolders @ level.
the result output console should list of file names no extension line line copy , pasted in application.
at moment trying this, in output console several meta information , not simple list.
get-childitem -path c:\xx\x-recurse -file | sort length –descending could please provide me hints?
if sorting length not necessity, can use -name parameter have get-childitem return name, use [system.io.path]::getfilenamewithoutextension() remove path , extension:
get-childitem -path .\ -filter *.js -recurse -file -name| foreach-object { [system.io.path]::getfilenamewithoutextension($_) } if sorting length desired, drop -name parameter , output basename property of each fileinfo object. can pipe output (in both examples) clip, copy clipboard:
get-childitem -path .\ -filter *.js -recurse -file| sort-object length -descending | foreach-object { $_.basename } | clip if want full path, without extension, substitute $_.basename with:
$_.fullname.remove($_.fullname.length - $_.extension.length)
Comments
Post a Comment