Skip to content Skip to sidebar Skip to footer

How To Modify Powershell Code So That Hyperlinks Are Only Created For The Files But Not The Directories?

I'm using the code below to generate Index.htm page. The code works great, but the only thing that I don't want inside that Index.htm page is to have the hyperlinks for directories

Solution 1:

You can filter out folder in this way:

Get-ChildItem $basedir -Force | ? { -not $_.psiscontainer } | ... rest of your code ...

in powershell V3

Get-ChildItem $basedir -Force -file | ... rest of your code ...

Solution 2:

What C.B. said. Another option, since you want only .htm files, would be filtering those files in Get-ChildItem:

Get-ChildItem $basedir -Filter "*.htm" -Force | ...

Post a Comment for "How To Modify Powershell Code So That Hyperlinks Are Only Created For The Files But Not The Directories?"