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

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
Hackoo
Posts: 103
Joined: 15 Apr 2014 17:59

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

#1 Post by Hackoo » 08 Jun 2021 02:50

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 "

penpen
Expert
Posts: 1991
Joined: 23 Jun 2013 06:15
Location: Germany

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

#2 Post by penpen » 08 Jun 2021 08:23

I'm just curious - how did you create that file in windows?

penpen

jfl
Posts: 226
Joined: 26 Oct 2012 06:40
Location: Saint Hilaire du Touvet, France
Contact:

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

#3 Post by jfl » 19 Jun 2021 12:11

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.

Post Reply