Q: How to give extensionless files an extension in SubFolders I have a parent folder with 100s of subfolders. In those there are random files that do not have any extension applied to them.
I'm trying to use PS to apply a .txt extension to any file found that just doesn't have an extension.
Things I've attempted:
Get-ChildItem G:\Those -Filter {!($_.Extension)} -Recurse |
    Rename-Item -NewName {$_.DirectoryName + '.txt'}

Get-ChildItem G:\Those (gci -File -Recurse | ?{!($_.Extension)}) |
    Rename-Item -NewName {$_.Directory.Name + '.txt'}

This one works if I have a file extension but I don't know how to convert it to only find files without an extension.
Get-ChildItem G:\Those -Filter *.ext -Recurse |
    Rename-Item -NewName {$_.Directory.Name + '.txt'}

I'm getting this error:

Rename-Item : Cannot rename the specified target, because it represents a path or
device name.
At line:1 char:63
+ ... {-not $_.Extension} | Rename-Item -NewName {$_.DirectoryName+'.txt'}
+                           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     + CategoryInfo          : InvalidArgument: (:) [Rename-Item], PSArgumentException
     + FullyQualifiedErrorId : Argument,Microsoft.PowerShell.Commands.RenameItemCommand


A: I figured it out in a roundabout way, but if someone could provide a one-liner for this I would love you.
{-not $_.Extension} got me those files but the rename wouldn't work until I changed $_.DirectoryName+ to $_.FileName+ with the -File added before -Recurse.
This actually renamed the files that had no extension to just ".txt"  
Name that they all had the same name I used my original command to rename anything .txt to $_.DirectoryName+'.txt',  which did the trick.
