1.

Solve : Delete A File With No Visible Characters.?

Answer»

Hey Guys,

I have a program that keeps creating files of 1KB (on Windows XP), but the files contain no characters. I already have a script going that deletes all the files in that same directory that are 0KB, but now I wish to have a script that deletes all files that have no visible characters in them instead, regardless of file size.

Does anyone have any ideas how to do this?

Thank you for your TIME.how about;



rem create a variable to locate the file, including path
set filepath="C:\path\to file.txt"

rem pull first line out of file
set /p file=<%filepath%

rem if first line is empty, delete the file
if %file% == "" (del %filepath%) else file contains information.


hope it helps

Quote from: kaydo on June 17, 2008, 08:23:42 AM

I have a program that keeps creating files of 1KB (on Windows XP), but the files contain no characters.

If there were no charactors, the file would be zero bytes. What you meant to say was that "the files contain no visible characters."
Is it possible the program needs that file (maybe a LOG or something).

I don't see any reason why it needs to be deleted. It's not taking up any space.
However, if this file is on the desktop, then I UNDERSTAND why you want to delete it.wouldnt be easier to use the sort command, you could create a FOR loop that goes through ever folder in your drive and ever time it changes folders, it uses the sort command to sort the files out and then delete em. How about letting us in on what program is doing this ? ?Quote from: blastman on June 17, 2008, 08:31:30 AM
how about;



rem create a variable to locate the file, including path
set filepath="C:\path\to file.txt"

rem pull first line out of file
set /p file=<%filepath%

rem if first line is empty, delete the file
if %file% == "" (del %filepath%) else file contains information.


hope it helps



Thank you very MUCH for the responses. The above worked for me w/ a little bit of modification. I appreciate it very much. I'm just pleased something I posted helped someone!!!



Discussion

No Comment Found