Reputation: 43833
I have a folder in windows that's name is RESIDENCES INC.
. The problem is this is actually an invalid foldername because of the period in it. If I try to delete it, it says
Could not find this item. This is no longer located in <path to folder>. Verify the item's location and try again.
How can I remove it with code?
Upvotes: 0
Views: 77
Reputation: 59782
That's weird, might be a Windows thing? It worked fine for me:
PS /home/Documents/test> mkdir "RESIDENCES INC."
PS /home/Documents/test> gi './RESIDENCES INC./'
Directory: /home/Documents/test
Mode LastWriteTime Length Name
---- ------------- ------ ----
d---- 3/18/2021 12:04 AM RESIDENCES INC.
PS /home/Documents/test> (gi './RESIDENCES INC./').FullName
/home/Documents/test/RESIDENCES INC./
PS /home/Documents/test> Remove-Item (gi './RESIDENCES INC./').FullName -Force
PS /home/Documents/test> (gi './RESIDENCES INC./').FullName
Get-Item: Cannot find path '/home/Documents/test/RESIDENCES INC./' because it does not exist.
PS /home/Documents/test>
Can you paste the command you're using to delete the folder?
Upvotes: 2