How to? Find out the total allocated size of a directory tree...

May 24, 2010
855
0
Northlake, Il
Rex has indicated to me that the above is already possible in TCC, but he didn't tell me how to do it. Yes, "%@FilesSize[/S *,b,a]" will return the total allocated size of all of the files in the current directory tree, but that number is not the total size of the directory tree because it doesn't include the allocated size(s) of the directory "files" (for want of a better term) themselves (which, of course, are not really files and therefore not counted (as far as I can tell) by '%@FileSize"). How does one determine the total allocated size of a directory tree, directory "files" as well as the files themselves? The point is to know whether a given directory tree will fit on a flash drive of a given size/what size flash drive is needed to hold a given directory tree.
 
May 20, 2008
11,401
99
Syracuse, NY, USA
"Directory files", as you called them, don't have an allocated size (or rather their allocated size is zero because they contain no **data**). Directories are merely logical structures, entries in the volume's MFT (master file table, SystemVolumeInformation?). Files use space in the MFT, too, but the amount of such space (used by anything), is not (readily, at least) available to, nor should it be of any interest to, the user.
 
May 24, 2010
855
0
Northlake, Il
Vince, I am aware the small files fit entirely in the MT. I was also under the distinct impression that small directories are contained there also, but large directories are not contained in the MFT just as large files are not contained in the MFT. But the real bottom line is that that is irrelevant to me: My only goal (and I really don't care how I achieve it) is to figure out how much allocated space a directory will take up on a flash drive/FAT volume so I can know ahead of time if the directory tree will fit. And this has actually come up because @FileSize[/S *,b,a] came up with a number that indicted the directory tree would fit on the flash drive, but when it came right down to it (i.e., actually trying to copy it there) it did not fit. Maybe what I want to accomplish is basically impossible. (I am also aware that the amount of space taken up will vary according to the cluster size of the FAT volume. But the bottom line is that fact only makes it more impossible because even @FileSize[/S *,b,a] won't give the correct results, particularly if the cluster size of the FAT volume is larger than the cluster size of the source drive.)
 

rconn

Administrator
Staff member
May 14, 2008
12,345
150
Directories are always 0 bytes, and don't take up any space on the file system, regardless of the number of files in the directory.

There isn't any internal function or command in TCC that will convert allocated space on NTFS to that on a random FAT / VFAT drive. The only way to do that is for you to loop through every directory & file, compute the allocation space that will be required for your target drive, and add it to the total allocated space necessary.

A better approach would be for you to reformat your target drive to NTFS. Unless you like sticking needles in your eyes, there's not much to be gained by using FAT.
 
May 20, 2008
3,515
4
Elkridge, MD, USA
I had written a batch program long ago for calculating file space required for a directory tree based on allocation unit size. It could not take into consideration the size of directory pseudofiles on FAT drives, though it would be possible to do that, assuming a simple directory entry size (i.e., for a file which whose LFN and SFN are the same) of 32 bytes. With some research one could determine the algorithm to determine the space requirement for an LFN based on its length. IIRC the root directory of a FAT drive is limited, and is stored on disk in a special area adjacent to the FAT.

The problem about reformatting is (at least on my systems) that USB drives (and virtual drives, e.g., SD cards) are usually formatted FAT/VFAT, and there is no program available to reformat them for NTFS (which I would love to do to be able to use junctions, hard links, compressed files and encrypted files). The formatting program incorporated into WinXP does not work on USB drives... I would be glad to hear about sucn a program! It would also be useful to repair bootable hard disk data structures when the drive is removed and installed in an external carrier.
 

Charles Dye

Super Moderator
Staff member
May 20, 2008
4,461
88
Albuquerque, NM
prospero.unm.edu
The problem about reformatting is (at least on my systems) that USB drives (and virtual drives, e.g., SD cards) are usually formatted FAT/VFAT, and there is no program available to reformat them for NTFS (which I would love to do to be able to use junctions, hard links, compressed files and encrypted files). The formatting program incorporated into WinXP does not work on USB drives...

Eh? Sure it does; see the /FS: option. You may have to "optimize for performance" first; see e.g. http://www.makeuseof.com/tag/how-to-optimize-usb-drive-with-ntfs/

I know that you can also do it using DISKPART.EXE in Windows 7; don't know whether that approach works in XP.
 
May 24, 2010
855
0
Northlake, Il
Thank you, everyone. It would appear that reformatting them to NTFS is the (only really practical!) solution. I knew how to do that (my RAM disk is NTFS, although it's FAT as delivered from the software vendor), I was just reluctant, for some truly unknown reason, to do that to a Flash drive. (After all, the idea of it ever being plugged into a non-Windows NT and its successors machine is virtually nil.)
 
Similar threads
Thread starter Title Forum Replies Date
J ffind does not find files Support 4
Alpengreis List command: text truncated in find box (german) Support 9
R FIND command error Support 9
vefatica Find Files/Text dialog: does it work? Support 0
T FFind - can we display n number of lines after the find? Support 2
R How to? Find a specific file in subfolders Support 11
Patulus TCHistoryLog: TCC: (Sys) The system cannot find the path specified Support 15
D unzip fails to find valid license Support 3
R Find in screen buffer - find next behavior Support 0
thedave Problem chaining piped FIND commands in BTM Support 7
D CD doesn't always find everything Support 8
B Fixed FFIND doesn't find last character in file without CR/LF at EOF Support 1
M Fixed Cannot use the "Browse..." function in "Find files/text" dialogbox Support 2
vefatica FFIND /S, find directory with specified name? Support 7
D Why doesn't ffind find directory? Support 3
nikbackm How to? Find duplicate lines in text file Support 0
P OK, I can't find how to do this, but I know you wizards will... Support 5
noahcoad WAD cmd.exe under tcc doesn't find apps Support 4
S How to? Find installer downloaded by "option /u"? Support 11
G Find files but ignore file extension in search Support 2
S CDD Doesn't Find Directory? Support 3
L File association: System cannot find the associated program Support 30
R How to use ffind to find older files? Support 9
Charles Dye Edit / Find dialog Support 0
J Find Files - changing folder Support 1
BobK Error from START cmd, "cannot find the file" Support 16
D ACTIVATE doesn't find windows Support 7
R A problem using find in list when word wrap? Support 2
nikbackm Find out when a process has stopped Support 5
J Find failure dialog box failure Support 0
J Problem with Find dialog Support 3
J Problem with %var:find=replace% syntax Support 5
S LIST and F for find Support 4
M TCC cannot find the path specified Support 4
M TCC Can't find WScript.exe where it says it is Support 0
Joe Caverly Total Command? Support 4
R Fixed Bytes Allocated Total Incorrect in V17 b52 Support 1
vefatica DIR /S ... grand total? Support 3
vefatica @FILESIZE[] ... allocated ... unexpected results Support 0
rps @FILESIZE[....,a] allocated size not matching Dir results Support 8
rps Fixed @filesize[...,a] space allocated values incorrect Support 2
vefatica @FILESIZE ... allocated space Support 7

Similar threads