Darien Posted October 21, 2017 Share Posted October 21, 2017 (edited) Hello, Why do the results of the "DriveGetSize" and "DriveSpaceTotal" commands do not match, as seen in the example below? MsgBox ( 0 , "" , Round ( DriveSpaceTotal ( "C:" ) / 1024 ) & Chr(13) & Round ( DirGetSize ( "C:" ) / 1024 / 1024 / 1024 ) ) Edited October 21, 2017 by Darien Link to comment Share on other sites More sharing options...
jchd Posted October 21, 2017 Share Posted October 21, 2017 Because the two functions don't return the same value since they don't count the same thing (total space != dir size). And reread what you write: "DriveGetSize" and "DriveSpaceTotal" while you invoke DirGetSize and DriveSpaceTotal. This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
Darien Posted October 21, 2017 Author Share Posted October 21, 2017 (edited) So how would I know if a device has the space needed to copy a particular directory? Edited October 21, 2017 by Darien Link to comment Share on other sites More sharing options...
jchd Posted October 21, 2017 Share Posted October 21, 2017 DriveSpaceFree() is presumably better suited to return available free space on a drive than any other function intended to count the space used by a directory (DirGetSize) or the total size of a drive (DriveSpaceTotal). This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
iamtheky Posted October 22, 2017 Share Posted October 22, 2017 Still my favorite, via @rover Skysnake 1 ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__) Link to comment Share on other sites More sharing options...
Darien Posted October 22, 2017 Author Share Posted October 22, 2017 (edited) I assume "DriveSpaceTotal" works similarly to "DriveSpaceFree", so I asked him. But if the result of "DriveSpaceFree" does not match the "DirGetSize" result of the directory I want to copy to that device, I will not know if the directory will fit or not. Edited October 22, 2017 by Darien Link to comment Share on other sites More sharing options...
jchd Posted October 22, 2017 Share Posted October 22, 2017 A directory doesn't have its own free space. The unused or free or available space on a drive is returned by DriveSpaceFree. 20 minutes ago, Darien said: I assume "DriveSpaceTotal" works similarly to "DriveSpaceFree" Total ≥ Free ! A 16Gb USB key has around 16Gb total space once formatted but has anything between that and 0 free space, depending on the size already used by files and directories. DirGetSize sums up the size of all files and directories found under a given path. Skysnake 1 This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
RTFC Posted October 22, 2017 Share Posted October 22, 2017 (edited) It's also worth mentioning that the amount of space needed to store files is usually a bit more than the reported file size, due to storage granularity. Any advanced file system (e.g. FAT, NTFS) will divide a formatted storage medium into fixed-size chunks (e.g., 4 Kb or 64 Kb, usually provided as a formatting option) and allocate one or more of these chunks to a particular file as needed. You can witness this difference yourself if your right-click on a file in the file manager and select "Properties;" you'll see separate entries for "Size" and "Size on Disk." In some file systems, the content of tiny files maybe stored with the directory entry description itself, so file size on disk is reported as zero. Larger files will be rounded up in size on disk to the next-larger integer number of chunks. So it's not as straightforward as simply adding all file sizes in a directory, and see if that will fit. Instead, to be safe, when establishing whether a bunch of files will fit, round each one's size up to the next-larger integer number of storage chunks, and sum those (do NOT add all file sizes, and round up that total once; that's not the same thing). Edited October 23, 2017 by RTFC correction, clarification My Contributions and Wrappers Spoiler BitMaskSudokuSolver BuildPartitionTable CodeCrypter CodeScanner DigitalDisplay Eigen4AutoIt FAT Suite HighMem MetaCodeFileLibrary OSgrid Pool RdRand SecondDesktop SimulatedAnnealing Xbase I/O Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now