0

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?

1
  • Can you show us how you're attempting to delete it? Commented Mar 18, 2021 at 3:15

1 Answer 1

2

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?

Sign up to request clarification or add additional context in comments.

1 Comment

is interesting way to do, but does not work for me

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.