3

I'm using UrbanCode Deploy for windows code deployments, and in my folder I've created a folder '.' . I've tried all the powershell remove-item commands and flags I can think of, I've tried robocopy move / purge copying it somewhere else, and run a chkdsk with no reported errors.

When I delete it manually I get 'Error 0x80070091: The directory is not empty'.

When I try and delete it through powershell I get 'Get-ChildItem : The path is not of a legal form'

If I open the '.' folder, it's as if I did 'ls -l ./'. If I go one deeper I get an error 'This file path refers to a location that is unavailable.'

Any ideas how to delete this folder?

8
  • Could you share the exact code you are trying? I have a hunch that you are not escaping the '.', and thus power shell is treating it like a regex for any character. If this is the case, it can be solved by replacing '.' with '/.'. Jan 13 '17 at 13:26
  • From the parent folder I'm trying 'Remove-Item ./* -force -recurse'. Even doing an ls -l, or Get-ChildItem -force throws the error 'the path is not of a legal form' It's not part of code or anything, just have this rogue folder that I'm trying to remove. Also the creation of the folder '.' was not purposefully. I'm not sure how it got there in the first place.
    – pcort
    Jan 13 '17 at 13:30
  • An update, I can copy the parent folder and move it somewhere innocuous for the time being. Unfortunately I can't copy/paste into the recycle bin :)
    – pcort
    Jan 13 '17 at 13:49
  • Okay, that changes the situation then. Can you just use Windows File Explorer to delete the folder? Or is that what you meant when you said "If I open the '.' folder, it's as if I did 'ls -l ./'. If I go one deeper I get an error 'This file path refers to a location that is unavailable.'" Jan 13 '17 at 13:50
  • If I use file explorer I get the error 'Error 0x80070091: The directory is not empty'.
    – pcort
    Jan 13 '17 at 13:52
1

Ended up finding a solution here, https://superuser.com/questions/78434/how-to-delete-directories-with-path-names-too-long-for-normal-delete

By opening up the parent directory in 7zip I was able to remove the directory by using shift+Delete on the folder. It looks like this is able to remove recursively created folders that are too long for file explorer to handle as well as illegal path names.

Thanks @frupfrup, googling 'windows long path remover' brought me to that superuser link! Also thanks @Kernal Sterns for other ideas.

1
  • nice to know, that 7zip can also handle it.
    – frupfrup
    Jan 16 '17 at 7:28
1

Here is a .bat file to delete . from the current directory:

@echo off
for %%* in (.) do set CurrDirName=%%~nx*
cd ..
rmdir /s %CurrDirName%

For anyone who is actually taking this seriously, please be aware this command is rather destructive.

0

i had an similar problem some months before. I also tried everything with Powershell / CMD and other Windows standard featueres. Nothing helped.

At least a colleague tried it with a third party tool named "Long path remover" (from "Thorsten Eggeling"). This tool could also remove folders with not compliant names. But i don't find it on the internet anymore... Maybe you can or you try it with an similar tool that may help you. Maybe an other remover tool could delete it too.

EDIT: but it is very sad, that there is no Windows integrated way to delete this folder... or at least no easy way... maybe someone else has an good idea.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.