Page 1 of 2 12>
Topic Options
#113623 - 2004-02-09 01:28 PM please please help!!!
juanbabi Offline
Fresh Scripter

Registered: 2004-02-09
Posts: 15
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!!!

Top
#113624 - 2004-02-09 01:37 PM Re: please please help!!!
AzzerShaw Offline
Seasoned Scripter
****

Registered: 2003-02-20
Posts: 510
Loc: Cheltenham, England
juanbabi
Can you be a bit clearer on what you want please? Can you also state your Operating system

Aaron
_________________________
If at first you don't succeed, try again. Then quit. There's no use being a damn fool about it. - W.C Fields

Top
#113625 - 2004-02-09 01:46 PM Re: please please help!!!
juanbabi Offline
Fresh Scripter

Registered: 2004-02-09
Posts: 15
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.

Top
#113626 - 2004-02-09 01:50 PM how to delete empty files
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
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.
_________________________
!

download KiXnet

Top
#113627 - 2004-02-09 01:58 PM Re: how to delete empty files
juanbabi Offline
Fresh Scripter

Registered: 2004-02-09
Posts: 15
how I need to save the script?
as script.kix?
the folder size is 180 giga.

is it a problem?

Top
#113628 - 2004-02-09 02:02 PM Re: how to delete empty files
AzzerShaw Offline
Seasoned Scripter
****

Registered: 2003-02-20
Posts: 510
Loc: Cheltenham, England
Your asking a question there that can easily be answered by reading the Kix manual!
_________________________
If at first you don't succeed, try again. Then quit. There's no use being a damn fool about it. - W.C Fields

Top
#113629 - 2004-02-09 02:41 PM Re: please please help!!!
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
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?

Top
#113630 - 2004-02-09 02:52 PM Re: please please help!!!
juanbabi Offline
Fresh Scripter

Registered: 2004-02-09
Posts: 15
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!!

Top
#113631 - 2004-02-09 03:03 PM Re: how to delete empty files
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
k, then...
what about reading the manual then?
or at minimum a piece of it or kixtart starter's guide from FAQ forum?
_________________________
!

download KiXnet

Top
#113632 - 2004-02-09 03:13 PM Re: how to delete empty files
juanbabi Offline
Fresh Scripter

Registered: 2004-02-09
Posts: 15
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 !!

Top
#113633 - 2004-02-09 03:15 PM Re: how to delete empty files
juanbabi Offline
Fresh Scripter

Registered: 2004-02-09
Posts: 15
where can I find some simple examples?


thanks

Top
#113634 - 2004-02-09 03:20 PM Re: how to delete empty files
AzzerShaw Offline
Seasoned Scripter
****

Registered: 2003-02-20
Posts: 510
Loc: Cheltenham, England
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
_________________________
If at first you don't succeed, try again. Then quit. There's no use being a damn fool about it. - W.C Fields

Top
#113635 - 2004-02-09 03:21 PM Re: how to delete empty files
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
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 ]


Edited by Jochen (2004-02-09 03:28 PM)
_________________________



Top
#113636 - 2004-02-09 03:23 PM Re: how to delete empty files
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
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.
_________________________
!

download KiXnet

Top
#113637 - 2004-02-09 03:26 PM Re: how to delete empty files
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
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).
_________________________
!

download KiXnet

Top
#113638 - 2004-02-09 03:31 PM Re: how to delete empty files
juanbabi Offline
Fresh Scripter

Registered: 2004-02-09
Posts: 15
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

Top
#113639 - 2004-02-09 03:46 PM Re: how to delete empty files
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
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.

Top
#113640 - 2004-02-09 04:05 PM Re: how to delete empty files
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
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.
_________________________
!

download KiXnet

Top
#113641 - 2004-02-09 04:33 PM Re: how to delete empty files
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
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.

Top
#113642 - 2004-02-09 05:06 PM Re: how to delete empty files
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
Lonk - The links and content are updated to the new board format. Thanks for the heads-up.

Kent
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
Page 1 of 2 12>


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 464 anonymous users online.
Newest Members
gespanntleuchten, DaveatAdvanced, Paulo_Alves, UsTaaa, xxJJxx
17864 Registered Users

Generated in 0.099 seconds in which 0.054 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org