Windows – How to delete a folder with “illegal” characters

osx-mountain-lionpowershellwindows 7

I plugged my USB flash memory stick into a Mac and it gained some unwanted hidden folders. (See the question Prevent MacOS from making .* and ._* files for prevention.)

I'd now like to remove these from my drive but I ran into an issue. Inside the fseventsd folder is a subfolder that is not shown unless I disable "Hide protected operating system files" in folder options. I am then shown a folder icon with no name, and attempting to delete it results in no action and no error. Attempting to open it results in the error:

E:\fseventsd\ is not accessible

The filename, directory name, or volume label syntax is incorrect.

So I took a look using command prompt:

Command Prompt Hidden Folder View

I must admit, had I not known the parent folder was from Mac OSX I would have strongly suspected a virus, because the folder name renders as a smiley face in ASCII.

Apparently this is ASCII character "01":

Old ASCII chart

Any commands I issued in Command Prompt resulted in various syntax errors as well. I decided to try Powershell.

Unfortunately 1) I'm not very experienced with Powershell, and 2) it appears to have similar difficulty with the weird folder name. I got the following error in Powershell just trying to list the parent directory contents:

Get-ChildItem : Illegal characters in path.

Powershell Error

How can I delete this folder?

Best Answer

I was able to "fix" this by running chkdsk /f on the drive. It converted the fseventsd folder to a file which was easily deleted. However, I don't know if this "fix" was because the subfolder appeared broken to chkdsk, or if there was something else on the volume that allowed this to work.

Offering this as an answer in case it works for others.