juanbabi
(Fresh Scripter)
2004-02-09 01:28 PM
please please help!!!

I an new to kixstart and my boss asked me to enter to a share folder and delete all the files that there size is zero but dont delete any folders.this share folder is a lot og gigas. can some one help me write a script ?

thanks u very very much!!!


AzzerShaw
(Seasoned Scripter)
2004-02-09 01:37 PM
Re: please please help!!!

juanbabi
Can you be a bit clearer on what you want please? Can you also state your Operating system

Aaron


juanbabi
(Fresh Scripter)
2004-02-09 01:46 PM
Re: please please help!!!

I work on windows 2000 server.

there is a share on one computer \\computerneme\sharename .

in this share there are many diffarent files that there size is 0 kb.all those files must be deleted.

thanks.


LonkeroAdministrator
(KiX Master Guru)
2004-02-09 01:50 PM
how to delete empty files

would think you would go ahead and read manual.
doing that would reveal you the function called GetFileSize()

oh, providing proper title for your thread could also help you in getting help.


juanbabi
(Fresh Scripter)
2004-02-09 01:58 PM
Re: how to delete empty files

how I need to save the script?
as script.kix?
the folder size is 180 giga.

is it a problem?


AzzerShaw
(Seasoned Scripter)
2004-02-09 02:02 PM
Re: how to delete empty files

Your asking a question there that can easily be answered by reading the Kix manual!

Richard H.Administrator
(KiX Supporter)
2004-02-09 02:41 PM
Re: please please help!!!

Why do you need a script to do this? Do you need to run this often?

It it is a one-off clean-up, why don't you open the directory in Windows Explorer, sort by file size, then block select those with zero bytes and delete?


juanbabi
(Fresh Scripter)
2004-02-09 02:52 PM
Re: please please help!!!

I need to run this only once.

the problem with windows search is that I can find the files but there are thousends of tham so whan I try to mark tham to delete I can mark only 100-200 each time and whan I delete tham windows tries to refrash but It takes a lot of time untill it does.sometimes it even freeze (this folders has a lot of sub folders in total the sixe is 160 giga.

thanks!!


LonkeroAdministrator
(KiX Master Guru)
2004-02-09 03:03 PM
Re: how to delete empty files

k, then...
what about reading the manual then?
or at minimum a piece of it or kixtart starter's guide from FAQ forum?


juanbabi
(Fresh Scripter)
2004-02-09 03:13 PM
Re: how to delete empty files

Im reading it right now man!!
on page 22...

the issue is that I need it ASAP !!
so I reading the menual and also deleting the files manually. why can u help ?
It is not so simple to understand I never programed anything !!


juanbabi
(Fresh Scripter)
2004-02-09 03:15 PM
Re: how to delete empty files

where can I find some simple examples?


thanks


AzzerShaw
(Seasoned Scripter)
2004-02-09 03:20 PM
Re: how to delete empty files

I would suggest doing it manually then! Put the file in size order and start to delete 50 at a time or something!!

I think this is going to be your quickest resolve

Aaron


JochenAdministrator
(KiX Supporter)
2004-02-09 03:21 PM
Re: how to delete empty files

the script i could suggest would last much longer as the following method :

open the find files/folder dialog, browse to the folder in question (make sure that recurse subdirectories is checked). Search for *.* and in advanced tab select file size is at most 0KB. let the search run.
When finished mark on of those files and hit CTRL+A. This should mark all files the search has found, then simply delete them.

Trust me when I say that scripting it would take at least an hour


[edit: forget about that, obvíusly that option is ignored ]


LonkeroAdministrator
(KiX Master Guru)
2004-02-09 03:23 PM
Re: how to delete empty files

k, your task is not so simple as you might think.
you need something to recursively parse the folder structure.
for that, best options propably are listed in udf-collection:
http://www.gwspikval.com/jooel/UDF

see some of the dirlist() dirscan() or dirplus() udf's

now, to implement these with getfilesize() is nothing much more than something like:

for each $file in dirred_folder()
if 0=getfilesize($file)
del $file
endif
next


how to use udf's you can find out in the FAQ forum.


LonkeroAdministrator
(KiX Master Guru)
2004-02-09 03:26 PM
Re: how to delete empty files

here:
http://www.kixtart.org/ubbthreads/showflat.php?Cat=&Board=UBB10&Number=81658#Post81660

btw, kent or someone, the links inside the thread are aged (use the old board naming).


juanbabi
(Fresh Scripter)
2004-02-09 03:31 PM
Re: how to delete empty files

whan I do "at most 0 " i dont recive nothing in the output.

I need to put at least 1 kb. and than I recive a lot of resolts. my boss told mr that I need to chank some other folders to. 160 gig x3 files.

come on guys please help!!!

thanks


Richard H.Administrator
(KiX Supporter)
2004-02-09 03:46 PM
Re: how to delete empty files

We cannot help you to write a script as you do not have enough experience, and it is a more complicated issue than you think it is.

Here is a script which will do the job:
Code:
Break ON
$gDiscard=SetOption("Explicit","ON")

Dim $sStartDir,$sRoutine

$sStartDir="C:\temp"
$sRoutine="udfDeleteZeroLengthFile($$sEntry)"

udfEnumDir($sStartDir,$sRoutine)

Function udfEnumDir($sDir,$sCall)
Dim $sEntry,$sDiscard
$sEntry=Dir($sDir)
While Not @ERROR
If Not($sEntry="." OR $sEntry="..")
$sEntry=$sDir+"\"+$sEntry
If GetFileAttr($sEntry) & 16 udfEnumDir($sEntry,$sCall) EndIf
$sDiscard=Execute($sCall)
EndIf
$sEntry=Dir()
Loop
EndFunction

Function udfDeleteZeroLengthFile($sPath)
If Not (16 & GetFileAttr($sPath))
If GetFileSize($sPath)=0
If @ERROR=0
"File "+$sPath+" is zero length - deleting..." ?
Del $sPath
If @ERROR "Error deleting file: "+@ERROR+", "+@SERROR ? EndIf
EndIf
EndIf
EndIf
EndFunction



Change the variable "$sStartDir" to match the directory that you want to purge, and run the script to delete zero length files.

I strongly suggest that you backup the file store before you begin the delete.


LonkeroAdministrator
(KiX Master Guru)
2004-02-09 04:05 PM
Re: how to delete empty files

richard, what was that?
we can't write you the script and then you write it?

lol.

come on guys?
what is that?
you have a job position where you are expected to know something about computers.
if you don't, we can't teach you.


Richard H.Administrator
(KiX Supporter)
2004-02-09 04:33 PM
Re: how to delete empty files

Not quite - that was "we can't help you write it, so we'll have to write it for you".

Sometimes the language barrier (English and KiXtart) is too high for a newbie to jump.

In this case I perceived that the attempts to point him in the right direction so he could write the script himself and learn by doing it was doomed to irritate everyone because the task was not so simple.

Much better to have someone think "that's works, now how does it do it?" than to think "KiXtart is pants, I'll try another scripting language/board instead."

JuanBabi - if you have no scripting experience I suggest you start with some simpler tasks which don't have the sort of pressure on your time that this one had.

Also have a look at the scripts that are posted to the board, especially in the UDF forum. The UDF forum is more actively moderated and so the scripts tend to be better examples.


Kdyer
(KiX Supporter)
2004-02-09 05:06 PM
Re: how to delete empty files

Lonk - The links and content are updated to the new board format. Thanks for the heads-up.

Kent


juanbabi
(Fresh Scripter)
2004-02-09 10:31 PM
Re: how to delete empty files

Hi man !!

I really thank u very much.
A few weeks ago a friend of mine showed me kixstart so I use it to connect users to share printers based on ingroup.
It looks very complicated the code that u wrote I really hope that after it deletes the files I'll take a good look at it.

Thank u very much again.-U sure are a good person,u saved me a lot of work -thank u million times !!


NTDOCAdministrator
(KiX Master)
2004-02-10 02:41 AM
Re: how to delete empty files

Have not tried, but I bet this program do it in GUI

http://www.ztree.com/