hpmacro Posted September 25, 2010 Report Share Posted September 25, 2010 Hi, Is it possible to get not only the size of a folder but also the total number of files in that folder and store it in a variable? I hope someone can help! Best, Herbert Quote Link to comment Share on other sites More sharing options...
terrypin Posted September 26, 2010 Report Share Posted September 26, 2010 Hi Herbert, and welcome to the forum. I don't think there is a specific ME Pro command (or option within a command) for achieving that. If I was doing it, I'd get the macro to open a selected folder's properties and then apply an OCR utility to capture the Size and Number fields. Or you could do it with a Repeat with Folder loop, counting each file processed. Another alternative would be to use an AutoIt! script within your macro, as I'm sure that has commands for such basic functions. Maybe one of the AutoIt! experts can amplify? -- Terry, East Grinstead, UK Quote Link to comment Share on other sites More sharing options...
rberq Posted September 26, 2010 Report Share Posted September 26, 2010 I don't know an easy, straightforward way to do it. You could use the Program Launch command to run command.com, passing it a DOS "dir" command and directing output to a text file. For example, dir c:\foldername /s > c:\listfile.txt. Use appropriate options with "dir" if you want to include subfolders. Then use Text File Begin Process to read back the text file. The last couple lines should tell you number of files and total size, which you can extract into variables. When you get done with this macro you won't consider yourself a newbie any longer. Quote Link to comment Share on other sites More sharing options...
hpmacro Posted September 26, 2010 Author Report Share Posted September 26, 2010 thank you very much! I think I stay a newby and do it with the repeat with folder command and increment an integer variable. Best, Herbert Quote Link to comment Share on other sites More sharing options...
rberq Posted September 26, 2010 Report Share Posted September 26, 2010 Yes, "repeat with folder" is way easier, but doesn't give you size, which you said you wanted. Quote Link to comment Share on other sites More sharing options...
kevin Posted September 27, 2010 Report Share Posted September 27, 2010 You can calculate both the number of files and the total size like this: Variable Set String %FolderPath% to "e:\Download Files" Variable Set Integer %SizeOfFiles% to 0 // SizeOfFiles is a Large Integer variable Variable Set Integer %FileCount% to 0 Repeat with Folder %FolderPath% Variable Modify Integer %FileCount%: Increment Variable Set From File: Set to the Size of a File (%AFile%) // AFile is a Large Integer variable Variable Modify Integer: %SizeOfFiles% = %SizeOfFiles% + %FileSize% End Repeat Text Box Display: Results: Size of Folder and Number of Files A sample macro file is attached. Sample Size of Foler and Number of Files.mex Quote Link to comment Share on other sites More sharing options...
kunkel321 Posted September 27, 2010 Report Share Posted September 27, 2010 Just tried to post this, but it didn't work, will retry... Does anyone know if there is a registry value that could be read, that might have the folder property for "Contains: N Files, N Folders" ? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.