Is there any way in AHK to establish if the file is empty without reading or even opening it?
EDIT:
By "empty" I mean "containing no text".
By "text" I mean "any combination of non-white-space and white-space characters that is easily seen by a user with his own eyes (for example, by looking at the flashing cursor) when he opens the file by clicking its icon".
By "file" I mean only a .txt file.
By "reading a file" and "opening a file" I mean using AHK commands FileRead or FileOpen.
(just added these edits to my original post)
[solved] How to find out if file is empty without opening it? Topic is solved
[solved] How to find out if file is empty without opening it?
Last edited by Benny-D on 14 Aug 2019, 00:35, edited 5 times in total.
Re: How to find out if file is empty without opening it?
i think u would have to be a bit more precise with ur definitions of "empty", "reading" and "opening it"
an "empty" file saved as UTF8 with BOM still contains the 3 byte BOM, for instance
FileGetSize "opens" the file. as does, ultimately, any function, needing to perform operations on a file
an "empty" file saved as UTF8 with BOM still contains the 3 byte BOM, for instance
FileGetSize "opens" the file. as does, ultimately, any function, needing to perform operations on a file
Re: How to find out if file is empty without opening it?
- I see.swagfag wrote: ↑12 Aug 2019, 22:12i think u would have to be a bit more precise with ur definitions of "empty", "reading" and "opening it"
an "empty" file saved as UTF8 with BOM still contains the 3 byte BOM, for instance
FileGetSize "opens" the file. as does, ultimately, any function, needing to perform operations on a file
By "empty" I mean "containing no text".
By "text" I mean "any combination of non-white-space and white-space characters that is easily seen by a user with his own eyes (for example, by looking at the flashing cursor) when he opens the file by clicking its icon".
By "file" I mean only a .txt file.
By "reading a file" and "opening a file" I mean using AHK commands FileRead or FileOpen.
(just added these edits to my original post)
- flyingDman
- Posts: 2817
- Joined: 29 Sep 2013, 19:01
Re: How to find out if file is empty without opening it? Topic is solved
I use the following to delete 0 byte sized files:
Comes in handy once in a while.
Code: Select all
loop, %path%\*.*
if A_LoopFileSize = 0
{
filedelete %A_LoopFileFullPath%
list .= A_LoopFileFullPath "`n"
count++
}
if !count
count = no
msgbox %count% deleted file(s)`n%list%
14.3 & 1.3.7
Who is online
Users browsing this forum: Anput, Marium0505, Nerafius and 189 guests