Page 3 of 3 <123
Topic Options
#156919 - 2006-02-11 04:14 AM Re: Dir() Help
thepip3r Offline
Hey THIS is FUN
*****

Registered: 2005-03-02
Posts: 350
thanx bryce, i'll look into that...
Top
#156920 - 2006-02-11 08:20 PM Re: Dir() Help
thepip3r Offline
Hey THIS is FUN
*****

Registered: 2005-03-02
Posts: 350
Yo da man Bryce, here's how I ended up getting it by file extension. Thanx Les, NTDOC, and everyone else who helped as well! You guys all rock!

Code:
Break On
$ = SetOption("WrapAtEOL","On")


$root = "%userprofile%\desktop"
$ext = "mp3",
"avi",
"jpg",
"gif",
"wmv"

$folders = dirplus($root,'/ad /s1')
for each $folder in $folders
$folder.path ?
for each $e in $ext
$files = dirplus($folder.path,'/s /a-d /f '+$e)
for each $f in $files
$folsize = $folsize + $f.size
next
? $e + ": " + $folsize
$folsize=0
next
next

sleep 10


Top
#156921 - 2006-02-11 10:02 PM Re: Dir() Help
thepip3r Offline
Hey THIS is FUN
*****

Registered: 2005-03-02
Posts: 350
nother question I'm not really understanding as I've stepped through the code and don't see why this is happening..

when i run through the script, the writes to the screen show the information as it should be so I know that my loops are correct BUT when I try to write that information to a file, ONLY the very first extension gets reported.

code: Code:
If $open = 0
$folders = dirplus($root,'/ad /s1')
for each $folder in $folders
$folder.path ?
$ = WriteLine(1,$folder.path+',')
for each $e in $ext
$files = dirplus($folder.path,'/s /a-d /f '+$e)
for each $f in $files
$folsize = $folsize + $f.size
next
$e + ": " + $folsize ?
$ = WriteLine(1,0+$folsize+',')
$folsize = 0
next
$ = WriteLine(1,@CRLF)
next
Endif



File Output:
Quote:

,mp3,avi,jpg,gif,wmv,msi,
C:\Documents and Settings\cameron.wilson\Desktop\Fairchild Netlogon,000000
C:\Documents and Settings\cameron.wilson\Desktop\Fairchild Netlogon\kix,000000
C:\Documents and Settings\cameron.wilson\Desktop\KiX,000000
C:\Documents and Settings\cameron.wilson\Desktop\KiX\Archive,000000
C:\Documents and Settings\cameron.wilson\Desktop\Release,000000
C:\Documents and Settings\cameron.wilson\Desktop\test,325728400029017485822464



Screen Output
Quote:

C:\Documents and Settings\cameron.wilson\Desktop\Fairchild Netlogon
mp3:
avi: 0
jpg: 0
gif: 0
wmv: 0
msi: 0
C:\Documents and Settings\cameron.wilson\Desktop\Fairchild Netlogon\kix
mp3: 0
avi: 0
jpg: 0
gif: 0
wmv: 0
msi: 0
C:\Documents and Settings\cameron.wilson\Desktop\KiX
mp3: 0
avi: 0
jpg: 0
gif: 0
wmv: 0
msi: 0
C:\Documents and Settings\cameron.wilson\Desktop\KiX\Archive
mp3: 0
avi: 0
jpg: 0
gif: 0
wmv: 0
msi: 0
C:\Documents and Settings\cameron.wilson\Desktop\Release
mp3: 0
avi: 0
jpg: 0
gif: 0
wmv: 0
msi: 0
C:\Documents and Settings\cameron.wilson\Desktop\test
mp3: 3257284
avi: 0
jpg: 0
gif: 0
wmv: 2901748
msi: 5822464
Press any key to exit




** For some reason, it's only writing the mp3 entries into the file and then it stops writing. Any ideas?


Edited by thepip3r (2006-02-11 10:07 PM)

Top
#156922 - 2006-02-11 10:56 PM Re: Dir() Help
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
You write different to screen:
$e + ": " + $folsize ?

than to file:
$ = WriteLine(1,0+$folsize+',')
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#156923 - 2006-02-11 11:48 PM Re: Dir() Help
thepip3r Offline
Hey THIS is FUN
*****

Registered: 2005-03-02
Posts: 350
damnit Les. While you're right, I don't understand why. How does changing what I write to a file make the variable different? ..because it's just $folsize I want to write to the file...

Edited by thepip3r (2006-02-11 11:49 PM)

Top
#156924 - 2006-02-11 11:53 PM Re: Dir() Help
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
If you disect your concatenation and apply KiX logic to it, you should be enlightened.
Rule #1.
If you start with an integer, KiX converts the rest of the concatenation to integer, so:
0 (integer) + $folsize (converted to integer) + ',' (also now integer) = 0
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#156925 - 2006-02-12 12:13 AM Re: Dir() Help
thepip3r Offline
Hey THIS is FUN
*****

Registered: 2005-03-02
Posts: 350
Thanx Les, adding quotes around the 0 worked. I appreciate the explanation.
Top
#156926 - 2006-02-12 11:30 AM Re: Dir() Help
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
adding @crlf to the end of writeline also does help.
_________________________
!

download KiXnet

Top
Page 3 of 3 <123


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

Who's Online
0 registered and 1662 anonymous users online.
Newest Members
M_Moore, BeeEm, min_seow, Audio, Hoschi
17883 Registered Users

Generated in 0.07 seconds in which 0.033 seconds were spent on a total of 11 queries. Zlib compression enabled.

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