lovevibrations Posted October 14, 2004 Report Share Posted October 14, 2004 How can I determine a read-only property of a file with a macro? Quote Link to comment Share on other sites More sharing options...
joe Posted October 15, 2004 Report Share Posted October 15, 2004 Hello and welcome to the forum! This can be done through a batch file: attrib %1 > %2 and a macro: // T1 = DOS batch file // T2 = File to get attribute from // T3 = File to store results Variable Set String %T1% "c:\temp\test.bat" Variable Set String %T2% "c:\temp\xfer.zip" Variable Set String %T3% "c:\temp\results.txt" // Run the batch file and wait for the results to be written Program Launch: "%T1%" Wait for File Ready: " // Parse the results file Variable Set String %T4% from File: "%T3%" Replace "%T2%" with "" in %T4% Variable Modify String: Trim %T4% // Test for an "R" If Variable %T4% contains "R" Text Box Display: Else Text Box Display: End If Macro Return <REM2:><REM2:T1 = DOS batch file><REM2:T2 = File to get attribute from><REM2:T3 = File to store results><TVAR2:01:01:c:\temp\test.bat><TVAR2:02:01:c:\temp\xfer.zip><TVAR2:03:01:c:\temp\results.txt><REM2:><REM2:Run the batch file and wait for the results to be written><LAUNCHDEL2:0:01%T1%<PARAM>"%T2%" "%T3%"><WFREADY:000000:000005:000000%T3%><REM2:><REM2:Parse the results file><TVAR2:04:04:%T3%T><TMVAR2:21:04:00:001:000:%T2%><TMVAR2:01:04:00:000:000:><REM2:><REM2:Test for an "R"><IFVAR2:1:04:7:TR><TBOX4:T:4:CenterCenter000250000150:000: %T2% is a read-only file><ELSE><TBOX4:T:4:CenterCenter000250000150:000: %T2% is NOT a read-only file><ENDIF><MRETURN><REM2:> You will, of course need to change the files to suit your own needs. A word of explanation about parsing the results file is in order. On my system the resulting line contains 11 spaces and/or attributes along with a fullpath filename no matter if you supply the fullpath or not. So I simply remove the filename from T4 and then trim it before testing for an "R". I have attached the files to this post. Hope this helps! GetAttribute.zip Quote Link to comment Share on other sites More sharing options...
Noggin the Nog Posted October 15, 2004 Report Share Posted October 15, 2004 Hi Joe, I'm fairly rusty on DOS. I can't figure how the batch file parameters %1 and %2 get their values from the text strings %T1% through %T3%. I assume it's a background function of ME. %1 shoud be "c:\temp\xfer.zip", which is %T2%, so is there an offset, %1 = variable 2, or have I got the wrong end of the stick? Quote Link to comment Share on other sites More sharing options...
joe Posted October 15, 2004 Report Share Posted October 15, 2004 Noggin - The values being passed to batch file %1 and %2 reside in the Parameters field of the Program Launch command ("%T2%" "%T3%"). Variables are handled in Macro Express by simple substitution much like a #DEFINE so what the batch file receives are actually the two literals "c:\temp\xfer.zip" and "c:\temp\results.txt". Then the batch file replaces the first and second parameters (%1 and %2) with the passed literals. Which results in: attrib c:\temp\xfer.zip > c:\temp\results.txt Not the quotation marks ("%T2%" "%T3%") are important if you are passing filenames with spaces in them. Quote Link to comment Share on other sites More sharing options...
Noggin the Nog Posted October 15, 2004 Report Share Posted October 15, 2004 Hi Joe, Thanks for the pointer. I had figured what the attrib statement had to be but could not see how %1 was directed to %T2%, ditto for %2. On the Direct Editor listing you posted it can be seen but is not obvious from the Scripting Editor listing (which is what I read). The Help files don't seem very good in this area (Command Line/DOS/Batch operations). It is not clear in Help that the Program Parameters can be applied to basic DOS statements in this fashion. A few examples would be have been useful. Most of the Help is related to switches. Quote Link to comment Share on other sites More sharing options...
floyd Posted October 15, 2004 Report Share Posted October 15, 2004 Oh sure ... DOS programs like batch files are, after all, programs like any other program. This is really no different than calling any other MS program while passing it command line parameters. We are simply passing parameters to a "programmable" program ... something you create ... rather than a pre-written program like Excel, Word, and so forth. 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.