Page 1 of 1

[Solved] How to delete a file with zero byte created accidentally with name "Call" on Windows ?

Posted: 08 Jun 2021 02:50
by Hackoo
How to delete a file with zero byte created accidentally with name "Call" ?
I'm facing with this issue that i couldn't figure it out until now ?
I tried with command Del but no chance.

Code: Select all

@echo off
 set "targetdir=C:\FolderDir"
 for /f "delims=" %%a in ('dir/s/b/a-d "%targetdir%\*.*"') do ( if %%~Za equ 0 echo %%~na>>results.txt && del "%%~a" )
I tried also to remove the directory which contains this file "Call"

Code: Select all

RD /S /Q [ParentFolder with file Call Inside]
I tried with Powershell too :

Code: Select all

Get-ChildItem -Path "C:\MyFolderDir" -Recurse -Force | Where-Object { $_.PSIsContainer -eq $false -and $_.Length -eq 0 } | remove-item
EDIT : Problem is Solved here
Solution Provided by Compo on stackoverflow thanks to him :
Trailing spaces are not valid in Windows,I tried to delete it like this:

Code: Select all

Del /A /F "\\?\C:\Users\Hackoo\Desktop\Scripting\Call "

Re: [Solved] How to delete a file with zero byte created accidentally with name "Call" on Windows ?

Posted: 08 Jun 2021 08:23
by penpen
I'm just curious - how did you create that file in windows?

penpen

Re: [Solved] How to delete a file with zero byte created accidentally with name "Call" on Windows ?

Posted: 19 Jun 2021 12:11
by jfl
That kind of problem happened to me a few times already.
Usually because I had typed Windows cmd.exe commands by mistake in the Linux subsystem Bash prompt. Recently I created like this a file called NUL, which I had a hard time deleting when I finally noticed it on the Windows side of things :oops:

But there were a few cases where I'm pretty sure I had done _nothing_ in Unix, but I had had cmd.exe crashes that day while developing complex macros. So there must be an unidentified bug somewhere in cmd.exe that allows to create that kind of file.