文件名中的尾随空格 [英] Trailing whitespace in filename
问题描述
我尝试使用此答案中的批处理脚本为控制台中的某些文本上色.
I tried using a batch-script from this answer to color some text in the console.
不幸的是,我有一些意外的行为,将´3 :s
用作string
进行了通话,这创建了一个名为:3"的文件,并带有空白.
Unfortunately I had some unintended behaviour, using ´3 :s
as string
for the call, which created a file named: "┬┤3 ", with a trailing whitespace.
Windows(10)(使用NTFS的硬盘驱动器)以某种方式无法处理文件名中的尾随空格,因此我无法摆脱它.
Windows (10) (harddrive using NTFS) somehow can't handle a trailing whitespace in filenames, therefore I can't get rid of it.
我尝试在Windows资源管理器和Total Commander中使用delete
,rename
,move
-均失败.
I tried using delete
, rename
, move
in the Windows Explorer and Total Commander - all failed.
使用命令提示符:DEL
,MOVE
和其他命令会导致找不到"
Using the command prompt: DEL
, MOVE
and others results in a "cannot find"
使用ATTRIB
输出:符号链接┬┤3"的目标不存在"
Using ATTRIB
outputs: "target of symbolic link "┬┤3 " does not exist"
要在当前目录中创建这样的文件:
To create such a file in you current directory:
SETLOCAL EnableDelayedExpansion
for /F "tokens=1,2 delims=#" %%a in ('"prompt #$H#$E# & echo on & for %%b in (1) do rem"') do (
set "DEL=%%a"
)
call :colorEcho 09 "´3 :s `"
exit
:colorEcho
echo off
<nul set /p ".=%DEL%" > "%~2"
findstr /v /a:%1 /R "^$" "%~2" nul
del "%~2" > nul 2>&1i