AutoHotkey Community

It is currently May 26th, 2012, 3:53 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 11 posts ] 
Author Message
 Post subject: Folder-Size
PostPosted: October 21st, 2004, 3:50 pm 
Offline

Joined: September 24th, 2004, 3:00 pm
Posts: 814
Location: Germany
Hi,

I have a problem with the folder-size. If I use the example-script form the help-file it fails if there a files or folder with illegal filenames. I have some folders on a NT-Server which were created with a Macintosh. A Macintosh can write filenames with a / inside a name or a space at the end of the name. In this case a windows-client could not open the files, because it sees the wrong name (file1204 instead of file12/04). But in explorer it is possible to move folders with such items and it also calculates the right folder-size (on tooltip or properties-window). Is it possible to get the folder-size directly or to read out what the explorer has calculated?

Tekl


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 21st, 2004, 7:07 pm 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
That's a good question. Maybe do a "StringReplace All" on each filename prior to asking its size (to remove all the bad characters).


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 22nd, 2004, 7:51 am 
Offline

Joined: September 24th, 2004, 3:00 pm
Posts: 814
Location: Germany
Hi Chris,

the problem is, that loop will not look inside Folders with Unicode-Characters in the name. AHK will correctly exchange the Unicode-Character with a "?", but Loop can not handle this.

Maybe it's a bigger problem. I think supporting Unicode is not so easy.

Tekl


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 22nd, 2004, 1:56 pm 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
I get it, thanks for explaining. Try the following recursive script, which cleanses the folder names before accessing them. Add more StringReplace commands to remove all the "bad" characters:
Code:
; Calculate the size of a folder, including the files in all its subfolders:
SetBatchLines, -1  ; Make the operation run at maximum speed.
FolderSizeKB = 0
FileSelectFolder, OrigFolder
if OrigFolder =
   ExitApp
WhichFolder = %OrigFolder%
Gosub, GetFolderSize
MsgBox Size of %OrigFolder% is %FolderSizeKB% KB.
return

GetFolderSize:
MsgBox %WhichFolder%
Loop, %WhichFolder%\*.*, 1   ; Include both folders and files, but do not recurse.
{
   IfInString, A_LoopFileAttrib, D  ; It's a directory, so recurse into it.
   {
      StringReplace, WhichFolder, A_LoopFileFullPath, /,, All
      ; ... and any others that are needed.
      Gosub, GetFolderSize  ; Recursive call to self.
   }
   else ; It's just a normal file, so add its size to the total:
      FolderSizeKB += %A_LoopFileSizeKB%
}
return


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 25th, 2004, 11:00 am 
Offline

Joined: September 24th, 2004, 3:00 pm
Posts: 814
Location: Germany
Hi Chris,

thanks for the script. The Problem is, that A folder named "Folder 12/04" on a mac, becomes "Folder 12?04" for a AHK-Script, so it could work (because ? is a wildcard), but it doesn't, the script breaks.

If I copy the name to a unicode-Editor, the Char has Unicode F022. If AHK would support unicode in variables, this could work to test it:

Code:
Name = C:\Folder 12{ASC 61474}04
FileCreateDir, %Name%


Tekl


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 25th, 2004, 12:35 pm 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
Okay, thanks for following up on it. Unicode support in variables would probably be very difficult because it requires a new form of string storage internally, which affects nearly every aspect of the program. It would also signficantly increase the memory used by the program, as well as reduce performance (assuming everything became Unicode internally).

For a future version, I'm going to look into ways to provide more basic Unicode support for things such as the clipboard.

Quote:
Name = C:\Folder 12{ASC 61474}04
You probably know that "ASC" is currently only understood by the Send command. It has no special meaning anywhere else.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 25th, 2004, 4:22 pm 
Offline

Joined: September 24th, 2004, 3:00 pm
Posts: 814
Location: Germany
Chris wrote:
You probably know that "ASC" is currently only understood by the Send command. It has no special meaning anywhere else.


Yes I know, it was only a suggestion. Well, I don't know if Unicode is important. If all will grow up to much, it's not so good to implement it. Well, maybe a workaround could help. There must be a way to process unicode-Files/Folders via wildcards.

Tekl


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 1st, 2005, 10:29 am 
Offline

Joined: September 24th, 2004, 3:00 pm
Posts: 814
Location: Germany
Hi,

actually I have the problem again, because OS X writes Decomposed Unicode-Filenames to the server. Now I deal with DIRUSE.EXE from the resource kit.

Code:
RunWait, cmd.exe /c diruse.exe /M "C:\Folder" > C:\_tmp.tmp,,hide

FileReadLine, FSizeMB, C:\_tmp.tmp, 3

StringLeft,FSizeMB,FSizeMB,13
FSizeMB := Round(FSizeMB)


Tekl


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 1st, 2005, 1:51 pm 
There is a small utility in the AutoItList Yahoo Group (from AutoIt), called:

dirsize (by Olaf Köslich)

Quote:
dirsize [-switch] [dir]

switches:
-of fpath outputs to file fpath (not allowed with -oc)
-oc outputs to clipboard (not allowed with -of)
-fi formats output with ini-sections (not with -fd)
-fd outputs data only (same order as ini-sections, not with -fi))
-r scans directories recursive
-h prints this help (and nothing more)

dir directory to start scan from


Dunno if this one works for you, you can try it...

Not-logged-in-daonlyfreez


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: July 1st, 2005, 1:55 pm 
Sorry, forgot the link:

http://groups.yahoo.com/group/AutoItList/files/UTIL/

You need to sign-in to be able to download.

If you need the file, but don't wanna sign-in, PM me.

Still-not-logged-in-daonlyfreez


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: July 1st, 2005, 2:30 pm 
Offline

Joined: September 24th, 2004, 3:00 pm
Posts: 814
Location: Germany
Thanks, that's near the same like DIRUSE.EXE which I use.

Tekl


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 11 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 2 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group