eganopperman Posted August 29, 2004 Report Share Posted August 29, 2004 I need to set the values of two Macro Express variables: one, with the amount of free space on my backup drive, and the other, with the file size of the subdirectory I wish to backup. I want the macro to evaluate the two values so that if the file size of the subdirectory is greater than than the free space on the backup drive a popup message is triggered directing the operator to replace the backup drive. Does anyone know of an eloquent way of retreiving such information? If I can get it into an ascii or text file I then can have Macro Express retrieve it and set the variables. TIA. Quote Link to comment Share on other sites More sharing options...
joe Posted August 29, 2004 Report Share Posted August 29, 2004 Hello Egan! Here is one solution ... although eloquent is in the eye of the beholder . This macro uses the O/S's DIR command to get the size of a disk drive and also the size of all files in a folder. Just change the variables to suit your situation. I have attached a playable mxe file. // T1=Drive, T2=Output file, T3=Output folder, T4=Input folder Variable Set String %T1% "c:\" Variable Set String %T2% "FreeSpace.txt" Variable Set String %T3% "c:\Temp" Variable Set String %T4% "c:\Pgm3" // If output file exists then ersae it If File Exists "%T2%" Delete File or Files: "%T2%" End If // Get the drive free space Program Launch: "cmd" Wait for File Exist: "%T2%" Wait for File Ready: "%T2%" // Scan for the "bytes free" line Text File Begin Process: "%T2%" If Variable %T5% contains "bytes free" Break End If Text File End Process // Extract the drive size to D1 Replace "bytes free" with "" in %T5% Variable Modify String: Trim %T5% Variable Set Integer %N1% from Position of Text in Variable %T5% Variable Modify String: Delete Part of %T5% Variable Modify String: Trim %T5% Variable Modify String: Convert %T5% to decimal %D1% // Now get the sizes of the files within the input folder Delete File or Files: "%T2%" Program Launch: "cmd" Wait for File Exist: "%T2%" Wait for File Ready: "%T2%" // Scan for the "bytes free" line. Save the line number Variable Set Integer %N1% to 0 Text File Begin Process: "%T2%" Variable Modify Integer: Inc (%N1%) If Variable %T5% contains "bytes free" Break End If Text File End Process // Extract the folder size to D2 Variable Modify Integer: Dec (%N1%) Text File Begin Process: "%T2%" Text File End Process Replace "bytes" with "" in %T5% Variable Modify String: Trim %T5% Variable Set Integer %N1% from Position of Text in Variable %T5% Variable Modify String: Delete Part of %T5% Variable Modify String: Trim %T5% Variable Modify String: Convert %T5% to decimal %D2% Macro Return DriveAndFolderSizes.zip Quote Link to comment Share on other sites More sharing options...
eganopperman Posted August 30, 2004 Author Report Share Posted August 30, 2004 Thank you, Joe. I modified your macro and it allows me to do the comparison I sought. By the way, while I may have mis-used the word "eloquent" your macro is "elegant" (i.e. simple and concise). Quote Link to comment Share on other sites More sharing options...
sparkcity Posted August 2, 2005 Report Share Posted August 2, 2005 Do I copy and paste your code to the direct editor in ME? Sparks Quote Link to comment Share on other sites More sharing options...
randallc Posted August 2, 2005 Report Share Posted August 2, 2005 Hi, no, Joe's code here is not direct code to import; download his "zip", then extract the "mxe" file, then import it to your library as "playable macro import". best, Randall 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.