虽然听起来你最终通过使用WSL解决了这个问题,但我认为你可以在不安装WSL/Cygwin的情况下通过使用文件夹的
8.3短名称来处理这个问题。
要从资源管理器中获取当前目录的
cmd
提示符,你可以在“文件”菜单中使用“打开Windows Powershell”选项,然后在shell中输入
cmd
以切换到
cmd.exe
。
运行
dir /x
命令来列出当前目录的内容,并获取名为
*
的文件夹的短名称,然后通过其短名称来重命名它。
我使用WSL在我的Windows文件系统上创建了一个名为
*
的文件夹,然后按照上述步骤确定了它的DOS兼容短名称(在这种情况下是
21BA~1
),然后使用
cmd.exe
将其重命名为
star
。
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
'*'
,否则它会被视为通配符。 - Tetsujinls
命令已经直接从readdir()获取了字面字符串*
并将其传递回内核,而cp
错误消息也显示它尝试访问一个字面的*
(因此通配符扩展没有发生,多亏了反斜杠),然而两者都得到了操作系统的“否定”回应。 - user1686