21

Browsing old hard drives I came across this folder named *:

star

I cannot open, access or rename it from Windows.

windows error

I have tried accessing it through Moba Xterm, where I get

ls -l
ls: ./*: No such file or directory
cp \* star
cp: can't stat '*': No such file or directory

Is it corrupted? Is there any way to fix it?

2
  • 8
    Try referring to it as '*' in single quotes, otherwise it will be considered a wildcard.
    – Tetsujin
    Mar 9 at 11:38
  • 13
    This is Windows, so the problem is that it's considered a wildcard at a different layer than where the quotes are interpreted. At Bash shell level, a backslash is enough. But the ls command already gets the literal string * straight from readdir() and passes it back to the kernel, and the cp error message likewise shows it trying to access a literal * (so wildcard expansion hasn't happened thanks to the backslash), yet both get a "no" from the OS.
    – user1686
    Mar 9 at 12:05

3 Answers 3

41

* is one of the disallowed characters in Windows filenames (as wildcard expansion is done by the filesystem on Windows). It is, however, allowed on NTFS in general, so having such a directory doesn't indicate filesystem corruption, only that the directory was created using a different OS.

Try renaming it using the \\?\ NT paths from Cmd:

move \\?\E:\██████████████\* \\?\E:\██████████████\badfolder

(Specifically use 'move' and not 'ren(ame)' in this case, as the latter has its own special treatment for the * character.)

If that does not help, connect the disk to a system running Linux, or try to access it through WSL. Even WSL1 might work, as it bypasses all of the high-level Windows API.

(Windows ports of Linux tools that you find in e.g. MobaXterm or git-bash aren't going to help much, because they're still ordinary Windows programs in the end, and still subject to the same restrictions. On the other hand, WSL1 and the old Interix/SfU tools are completely different "subsystems" from Win32, sharing only the kernel, but unaffected by the filename restrictions.)

7
  • 9
    The move command did not seem to work. Accessing it through a Linux OS did the trick. Thank you very much for your assistance! Mar 9 at 13:29
  • 2
    I would guess that commanding from a shell in Cygwin might work as well. Mar 10 at 17:52
  • 2
    @CarlWitthoft: Cygwin programs are ultimately still just Windows programs, implementing a POSIX API on top of the WinAPI, unless I'm mistaken. Unlike WSL1, it doesn't have kernel support, which is why its emulation of syscalls like fork() is so expensive. This answer already explained that going through the WinAPI doesn't work. Mar 10 at 21:33
  • 1
    @PeterCordes Wrong, I'm not sure about the implementation details but I use Cygwin all the time to get around Windows-specific issues just like this and have done for years. It's also orders of magnitude faster than WSL1 and even WSL2. Mar 10 at 23:19
  • 2
    no need to use another OS, WinApi's NtCreateFile ignores that particular Windows restriction and allows you to create files/folders named * (why? don't know..)
    – hanshenrik
    Mar 11 at 1:12
7

While it sounds like you eventually worked around this by using WSL, I think you could have handled this without installing WSL/Cygwin by using the 8.3 short name for the folder.

To get a cmd prompt in the current directory from explorer, you can use the "Open Windows Powershell" option in the File menu, and then type cmd in the shell to switch to cmd.exe.

Open Windows PowerShell

Run dir /x to list the context of the current directory and get the short-name for the folder named *, then refer to the folder by its short name to rename it.

I used WSL to create a folder named * on my Windows filesystem, and then followed the steps above to determine its DOS-compatible short-name (21BA~1 in this case), and then rename it star using cmd.exe:

PS C:\Users\Nick\Scripts> cmd
Microsoft Windows [Version 10...]
(c) Microsoft Corporation. All rights reserved.

C:\Users\Nick\Scripts>dir /x
 Volume in drive C has no label.
 Volume Serial Number is ABCD-1234

 Directory of C:\Users\Nick\Scripts

03/11/2022  05:26 PM    <DIR>                       .
03/11/2022  05:26 PM    <DIR>                       ..
10/10/2020  04:30 PM             1,225 PORT-F~1.PS1 port-forward.ps1
03/11/2022  05:26 PM    <DIR>          21BA~1       
               1 File(s)          1,225 bytes
               3 Dir(s)  166,006,308,864 bytes free

C:\Users\Nick\Scripts>ren 21BA~1 star

C:\Users\Nick\Scripts>dir
 Volume in drive C has no label.
 Volume Serial Number is ABCD-1234

 Directory of C:\Users\Nick\Scripts

03/11/2022  05:40 PM    <DIR>          .
03/11/2022  05:40 PM    <DIR>          ..
10/10/2020  04:30 PM             1,225 port-forward.ps1
03/11/2022  05:26 PM    <DIR>          star
               1 File(s)          1,225 bytes
               3 Dir(s)  166,006,243,328 bytes free
1

fwiw a simple solution is to install Cygwin and rename the folder with it. lets say your folder path is C:\Users\hans\Desktop\* , open a Cygwin terminal and write

cd 'C:\Users\hans\Desktop'
mv '*' 'star'

and voila, your folder is now named star instead of *

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.