This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

alfabet

Old posts that have not been replied to for several years.
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

As I have seen on the TCL manual (http://tcl.activestate.com/man/tcl8.2.3/TclCmd/file.htm) I have found the "file size name" to get the size of a file and "file mtime name" for the last modified thing. Will this two work also for the dirs or only for files?

Also I have found some other nice things I can do with the file thing and I haven't thinked about using them on the web page generation. Neat.. :)
Once the game is over, the king and the pawn go back in the same box.
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

As I have tested and seen with:

bind dcc n tmp task:tmp

proc task:tmp { hand idx arg } {
global db
set file "pub/"
putlog "Size: [file size $file]"
}

the size works only for files. Seems that I have to get the size of all the files and then to add them to a variable and finaly that variable represends the size of the dir. Is there any other way to seee the dir's size? My alternative is bit messy but what a hell.. If there is no other I must do so.. Ce la vie.. :)

As for the "file mtime name" I have noticed that works for a dir. The only thing that I'm confused with is that I'm getting a result like this: 1042649520. How to make it look like eg. January 17, 2003?
Once the game is over, the king and the pawn go back in the same box.
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

Code: Select all

proc filefullsize {dir} {
  if {![file exists $dir]} { error "No such directory exists" }
  set c 0
  foreach a [glob -type f $dir] {
    incr c [file size $a]
  }
  return $c
}

Use the abov function like so.

Code: Select all

set directory "/file/audio/"
set filesizes [filefullsize $directory]
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

bind dcc n tmp task:tmp

proc task:tmp { hand idx arg } {
global db
set dir "files"
set c 0
foreach a [glob -type f $dir] {
incr c [file size $a]
}
putlog "Dir size: $c"
}

And I'm getting an error: Tcl error [task:tmp]: no files matched glob pattern "files". Also tryed with "/files/" and "files/" and the same result.
Once the game is over, the king and the pawn go back in the same box.
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

Do those directories exist?

"/files/" is a obsolute directory.
"files/" is relative to the current directory
"files" is also relative to the currect die. It simply doesn't have the trailing slash.
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

"files/" dir exists.
Once the game is over, the king and the pawn go back in the same box.
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

make it

Code: Select all

foreach a [glob -type f "${dir}*"] {
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Now works. As as sow, the result is in bytes, how to transfor it in KB and/or MB?

Oh, and also how to transform the result of the [file atime "${dir}"] in something more comestible like 17 Jan. 2003 @ 12:45 or something like this. I'm getting an result in seconds or something like this as far as I can see..
Once the game is over, the king and the pawn go back in the same box.
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

Do I have to keep quoting the Tcl manual.

See the "clock format" command for time conversion.

As for working out MB and so on, it's a case of simple math.

Bytes / 1024 = Kbytes
Kbytes / 1024 = Mbytes
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Figured out myself how to get the time: [clock format [file atime "${dir}"] -format {%A, %d %B %Y @ %H %M %S}]

but how to make the KB and MB calc?
Once the game is over, the king and the pawn go back in the same box.
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

PLEASE VISIT THIS PAGE

Try readin up about each command in the manual. I'm sure you will come to the correct command eventualy.

It's plain laziness, to know where the manual is, yet fail to try looking yourself, and wait for us to point it out.
s
spock
Master
Posts: 319
Joined: Thu Dec 12, 2002 8:40 pm

Post by spock »

/me gets his flamethrower
photon?
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

ppslim: I'm sorry If I have let you under the wrong impresion that I'm plain laziness.

I have come to the correct command eventualy, after reading your advice.
[expr 4/2] makes the calc thing. Seesh..

Thank you for your time, support and mostly for your kindly cooperation and sorry again..

spock: there is no need to be rude or something.. I haven't done you anything, or have I done?

Make your own mistakes, not somebody else's..
Once the game is over, the king and the pawn go back in the same box.
Locked