Jump to content
Macro Express Forums

Directory Modification


Recommended Posts

Hello.

 

I have been tinkering with Directory Modification and can't seem to get it to work.

 

<DELAY Flags="\x02" Time="750"/>
<REPEAT WITH FOLDER Path="E:\\" OnlyFiles="TRUE" Destination="%FilesinE%" FullPath="TRUE" ProcSubfolders="TRUE"/>
<VARIABLE SET FROM FILE Filename="%FilesinE%" Option="\x00" Date="\x00" Month="%Month%" Day="%Day%" Year="%Year%" Flags="\x07" _IGNORE="0x0007" _IGNORE="0x0003"/>
<VARIABLE SET INTEGER Option="\x0F" Destination="%Day1%"/>
<VARIABLE SET INTEGER Option="\x10" Destination="%Month1%"/>
<VARIABLE SET INTEGER Option="\x11" Destination="%Year1%"/>
<IF VARIABLE Variable="%Day%" Condition="\x00" Value="%Day1%" IgnoreCase="TRUE"/>
<AND/>
<IF VARIABLE Variable="%Month%" Condition="\x00" Value="%Month1%" IgnoreCase="TRUE"/>
<AND/>
<IF VARIABLE Variable="%Year%" Condition="\x00" Value="%Year1%" IgnoreCase="FALSE"/>
<VARIABLE MODIFY STRING Option="\x08" Destination="%FilesinE%" Variable="%FilesInECopy%"/>
<MACRO RUN Use_ID="FALSE" Name="CRLF" ID="-1" Wait="FALSE"/>
<VARIABLE MODIFY STRING Option="\x06" Destination="%FilesinE%" Value="%FilesInECopy%"/>
<VARIABLE MODIFY STRING Option="\x11" Destination="%FilesInECopy%" Filename="C:\\Documents and Settings\\Pat\\Desktop\\New Files Added to F.txt" CRLF="FALSE"/>
<END IF/>
<END REPEAT/>
<TEXT BOX DISPLAY Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs16 %FilesInECopy%\r\n\\par }\r\n" Left="Center" Top="Center" Width="278" Height="200" Monitor="0" OnTop="FALSE" Keep_Focus="TRUE" Mode="\x00" Delay="0"/>

 

There is a few other things bothering me about ME Pro. For some reason, when I "test run" the program, I see all the files moving along in "Debug - Show Variable Values". Now when I test the macro by moving a file into the directory folder, nothing happens in the "Show Variable Values" debug window. it's like it's standing still.

 

Also, after a few tests, I gave up on it for a few hours. Now when I came back and had Macro Express Closed, I decided to move a file into the specific folder and it seems like it took ten minutes for it to chew through the entire folder whereas before it took like 15 seconds. What's the deal?

 

Pat Gennarelli

Edited by kevin
changed 'codebox' tags to 'code' tags to eliminate horizontal scrolling
Link to comment
Share on other sites

It would be nice if you explained what it's supposed to do rather than having to be worked out. It's particularly difficult when the code does not work. My read is that you are trying to find all files on your E drive that were created today and make a list. The date stuff looks OK.

 

If you look at your line

Variable Modify String %FilesinE%: Copy Whole Text (%FilesInECopy%)

First of all I can't find where %FilesInECopy% is defined

Second, %FilesinE% is your filepath, why are you replacing it with %FilesInECopy% and then appending the same variable?

 

At the start I would save %T[99]% (my unset, designated null) or any blank value to C:\Documents and Settings\Pat\Desktop\New Files Added to F.txt to clear it (if it already exists).

I would ditch lines 12 to 14 and make 15:

Variable Modify String: Append %FilesinE% to text file, "C:\Documents and Settings\Pat\Desktop\New Files Added to F.txt"

This includes a CRLF. %FilesinE% is a text string of the full filepath of the current file that fits "today's" parameters. If that is not what you want some explanation please.

Link to comment
Share on other sites

Thanks John. I am not used to how variables are defined in this version. it was much easier in the last version. I didn't think it was my code, but rather maybe that the file sometimes take a few seconds sometimes to show in the folder while it's being dragged.

 

I guess it's just a matter of practice.

 

Thanks again.

 

I will post the solution for all when i get it down.

 

Pat

Link to comment
Share on other sites

Although several steps don't seem to have been needed, it is important when copying variables to note which variable is copied to which (stated in the dialog). That applies to both versions of ME. You also need to understand the differences between Save and Append (you may know that already).

 

(edit) Something else that may be of use to you later is that there are special variables for common paths. They are listed in Variables Set from Misc. If you want to add a file or address something to the Desktop you can use this as the path:

Variable Set From Misc:  "Path to Desktop" into %T[1]%
Variable Modify String %T[1]%: Append Text (myfile.txt)

T1 is now the full filepath to myfile.txt on the Desktop but the beauty of it is that it can be used on other PCs/users. "Path to Desktop" means the Desktop of the current user. In your case it's Pat. It would work on Fred's PC too. The "My Documents" path can be used the same way.

Edited by JohnS
Link to comment
Share on other sites

OK, I got it all figured out and it works!

 

Here is the code:

 

<VARIABLE SET STRING Option="\x03" Destination="%T[99]%" Filename="C:\\Documents and Settings\\Pat\\Desktop\\New Files Added to F.txt" Strip="FALSE"/>
<VARIABLE SET STRING Option="\x00" Destination="%T[99]%" Value=" "/>
<VARIABLE MODIFY STRING Option="\x11" Destination="%T[99]%" Filename="C:\\Documents and Settings\\Pat\\Desktop\\New Files Added to F.txt" CRLF="FALSE"/>
<DELAY Flags="\x02" Time="750"/>
<REPEAT WITH FOLDER Path="E:\\" OnlyFiles="TRUE" Destination="%FilesinE%" FullPath="TRUE" ProcSubfolders="TRUE"/>
<VARIABLE SET FROM FILE Filename="%FilesinE%" Option="\x00" Date="\x00" Month="%Month%" Day="%Day%" Year="%Year%" Flags="\x07" _IGNORE="0x0007" _IGNORE="0x0003"/>
<VARIABLE SET INTEGER Option="\x10" Destination="%Month1%"/>
<VARIABLE SET INTEGER Option="\x0F" Destination="%Day1%"/>
<VARIABLE SET INTEGER Option="\x11" Destination="%Year1%"/>
<IF VARIABLE Variable="%Day%" Condition="\x00" Value="%Day1%" IgnoreCase="TRUE"/>
<AND/>
<IF VARIABLE Variable="%Month%" Condition="\x00" Value="%Month1%" IgnoreCase="TRUE"/>
<AND/>
<IF VARIABLE Variable="%Year%" Condition="\x00" Value="%Year1%" IgnoreCase="FALSE"/>
<VARIABLE SET STRING Option="\x00" Destination="%FilesInECopy%"/>
<VARIABLE MODIFY STRING Option="\x08" Destination="%FilesinE%" Variable="%FilesInECopy%" _ENABLED="FALSE"/>
<MACRO RUN Use_ID="FALSE" Name="CRLF" ID="-1" Wait="FALSE" _ENABLED="FALSE"/>
<VARIABLE MODIFY STRING Option="\x06" Destination="%FilesInECopy%" Value="%FilesinE%"/>
<VARIABLE MODIFY STRING Option="\x12" Destination="%FilesInECopy%" Filename="C:\\Documents and Settings\\Pat\\Desktop\\New Files Added to F.txt" CRLF="FALSE"/>
<END IF/>
<END REPEAT/>

 

While the macro was running, I tried to add another file to the folder and it didn't pick it up. Is there a reason why? I thought ME could run multiple macros at once. I would assume that the same macro cannot be run at the same time? So how can I pickup an added file while the macro is running?

 

Pat

Link to comment
Share on other sites

I added more to the script and the CRLF is not appending. Is there something I am missing?

 

<VARIABLE SET STRING Option="\x00" Destination="%T[99]%" Value=" "/>
<VARIABLE MODIFY STRING Option="\x11" Destination="%T[99]%" Filename="C:\\Documents and Settings\\Pat\\Desktop\\New Files Added to F.txt" CRLF="FALSE"/>
<DELAY Flags="\x02" Time="750"/>
<REPEAT WITH FOLDER Path="E:\\" OnlyFiles="TRUE" Destination="%FilesinE%" FullPath="TRUE" ProcSubfolders="TRUE"/>
<VARIABLE SET FROM FILE Filename="%FilesinE%" Option="\x00" Date="\x00" Month="%Month%" Day="%Day%" Year="%Year%" Flags="\x07" _IGNORE="0x0007" _IGNORE="0x0003"/>
<VARIABLE SET INTEGER Option="\x10" Destination="%Month1%"/>
<VARIABLE SET INTEGER Option="\x0F" Destination="%Day1%"/>
<VARIABLE SET INTEGER Option="\x11" Destination="%Year1%"/>
<IF VARIABLE Variable="%Day%" Condition="\x00" Value="%Day1%" IgnoreCase="TRUE"/>
<AND/>
<IF VARIABLE Variable="%Month%" Condition="\x00" Value="%Month1%" IgnoreCase="TRUE"/>
<AND/>
<IF VARIABLE Variable="%Year%" Condition="\x00" Value="%Year1%" IgnoreCase="FALSE"/>
<VARIABLE MODIFY STRING Option="\x06" Destination="%FilesInECopy%" Value=" "/>
<VARIABLE MODIFY STRING Option="\x06" Destination="%FilesInECopy%" Value="%FilesinE%"/>
<VARIABLE MODIFY STRING Option="\x06" Destination="%FilesInECopy%" Value="%T[95]%" _ENABLED="FALSE"/>
<VARIABLE MODIFY STRING Option="\x12" Destination="%FilesInECopy%" Filename="C:\\Documents and Settings\\Pat\\Desktop\\New Files Added to F.txt" CRLF="FALSE"/>
<END IF/>
<END REPEAT/>
<UNLOCK PLAYER/>
<VARIABLE SET STRING Option="\x00" Destination="%FilesInECopy%" Value="%FilesInECopy%"/>
<MULTIPLE CHOICE MENU Style="\x00" Result="\x00" Dest="%FilesInECopy%" Options="%FilesInECopy%" Left="Center" Top="Center" Monitor="0" Width="443" Height="296" OnTop="FALSE"/>

Edited by kevin
changed 'codebox' tags to 'code' tags to eliminate horizontal scrolling
Link to comment
Share on other sites

Sorry, this one:

 

<LOCK PLAYER Wait="TRUE"/>
<VARIABLE SET TO ASCII CHAR Value="13" Destination="%T[95]%"/>
<VARIABLE SET TO ASCII CHAR Value="10" Destination="%T[96]%"/>
<VARIABLE SET STRING Option="\x00" Destination="%T[95]%" Value="%T[95]%%T[96]%"/>
<VARIABLE SET STRING Option="\x03" Destination="%T[99]%" Filename="C:\\Documents and Settings\\Pat\\Desktop\\New Files Added to F.txt" Strip="FALSE"/>
<VARIABLE SET STRING Option="\x00" Destination="%T[99]%" Value=" "/>
<VARIABLE MODIFY STRING Option="\x11" Destination="%T[99]%" Filename="C:\\Documents and Settings\\Pat\\Desktop\\New Files Added to F.txt" CRLF="FALSE"/>
<DELAY Flags="\x02" Time="750"/>
<REPEAT WITH FOLDER Path="E:\\" OnlyFiles="TRUE" Destination="%FilesinE%" FullPath="TRUE" ProcSubfolders="TRUE"/>
<VARIABLE SET FROM FILE Filename="%FilesinE%" Option="\x00" Date="\x00" Month="%Month%" Day="%Day%" Year="%Year%" Flags="\x07" _IGNORE="0x0007" _IGNORE="0x0003"/>
<VARIABLE SET INTEGER Option="\x10" Destination="%Month1%"/>
<VARIABLE SET INTEGER Option="\x0F" Destination="%Day1%"/>
<VARIABLE SET INTEGER Option="\x11" Destination="%Year1%"/>
<IF VARIABLE Variable="%Day%" Condition="\x00" Value="%Day1%" IgnoreCase="TRUE"/>
<AND/>
<IF VARIABLE Variable="%Month%" Condition="\x00" Value="%Month1%" IgnoreCase="TRUE"/>
<AND/>
<IF VARIABLE Variable="%Year%" Condition="\x00" Value="%Year1%" IgnoreCase="FALSE"/>
<VARIABLE MODIFY STRING Option="\x06" Destination="%FilesInECopy%" Value=" "/>
<VARIABLE MODIFY STRING Option="\x06" Destination="%FilesInECopy%" Value="%FilesinE%"/>
<VARIABLE MODIFY STRING Option="\x06" Destination="%FilesInECopy%" Value="%T[95]%" _ENABLED="FALSE"/>
<VARIABLE MODIFY STRING Option="\x12" Destination="%FilesInECopy%" Filename="C:\\Documents and Settings\\Pat\\Desktop\\New Files Added to F.txt" CRLF="FALSE"/>
<END IF/>
<END REPEAT/>
<UNLOCK PLAYER/>
<VARIABLE SET STRING Option="\x00" Destination="%FilesInECopy%" Value="%FilesInECopy%"/>
<MULTIPLE CHOICE MENU Style="\x00" Result="\x00" Dest="%FilesInECopy%" Options="%FilesInECopy%" Left="Center" Top="Center" Monitor="0" Width="443" Height="296" OnTop="FALSE"/>

Edited by kevin
changed 'codebox' tags to 'code' tags to eliminate horizontal scrolling
Link to comment
Share on other sites

I'll answer the first post before looking at the second. If you add a file and it is higher up the tree than where the macro is currently running, it will not pick it up. It has gone past. If it is lower on the tree it should be picked up.

 

If you want to continually monitor new files you will have to keep running the macro. If you do that there are two options.

 

Run again, deleting the existing list of files and going through the lot again.

 

Run again leaving existing list intact but checking each matching file found against what is already on the list (using Text File Process). In that case skip appending to the list. If it is not already on the list, append. Using this method the extra files will not be in tree order.

Link to comment
Share on other sites

First I'll explain the %T[99]% business. You don't set it, that is the whole point. It saves that step. If you never set a text variable it is equivalent to "". All you needed to do is change:

 

Variable Set String set %T[99]% to the contents of C:\Documents and Settings\Pat\Desktop\New Files Added to F.txt
Variable Set String %T[99]% to " "
Variable Modify String: Save %T[99]% to "C:\Documents and Settings\Pat\Desktop\New Files Added to F.txt"

to

Variable Modify String: Save %T[99]% to "C:\Documents and Settings\Pat\Desktop\New Files Added to F.txt"

You can do that with any UNSET text variable. I chose to use T99 in the days of ME3 because it was remote from the ones you usually use. It was easy to access in ME3 because you grab the slider of the UpDown box and zip to the bottom where T99 is. I never set T99 so that it is always "" or nothing and you have a ready-made nothing/blank.

 

 

Re the main code, I thought my comment was fairly clear, get rid of the old lines 12-14 and add the one I posted. I have no idea why you are still using %FilesInECopy%. This time you are appending a space to %FilesInECopy% which is previously unset, then appending the filename so you end up with the filename such as E:\my folder\myfile.txt preceded by a space. Is that what you really want? Perhaps it is. If I were doing this for my own use I would replace your:

Variable Modify String %FilesInECopy%: Append Text ( )
Variable Modify String %FilesInECopy%: Append Text (%FilesinE%)
Variable Modify String %FilesInECopy%: Append Text (%T[95]%)
Variable Modify String: Append %FilesInECopy% to text file, "C:\Documents and Settings\Pat\Desktop\New Files Added to F.txt"
End If
End Repeat
Unlock Player
Variable Set String %FilesInECopy% to "%FilesInECopy%"
Multiple Choice Menu:

with

Text Box Display: Current File  // display %FilesinE% for testing only
Variable Modify String: Append %FilesinE% to text file, "C:\Documents and Settings\Pat\Desktop\New Files Added to F.txt"
 End If
End Repeat
Program Launch: "New Files Added to F.txt" (Normal)
Parameters: 
Unlock Player

 

This time I don't have time to define all the variables again (which is what happens when you paste code). You will have to program yourself. Note that the Append must have CRLF checked and note my change for the variable in the final Multiple Choice Menu(??) which I have changed to a Text Box Display rather than a Multiple Choice Menu. Code below:

<TEXT BOX DISPLAY Title="Current File" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs16 \r\n\\par %FilesinE%\r\n\\par }\r\n" Left="Center" Top="Center" Width="624" Height="113" Monitor="0" OnTop="FALSE" Keep_Focus="TRUE" Mode="\x00" Delay="0"/>

I've put the Text Box Display inside the loop so you can check files before they are added to the list. Once the macro is working fine, you can delete or disable that command. When the list is finished, it is launched so you can look at it. Note that the full filepath "C:\Documents and Settings\Pat\Desktop\New Files Added to F.txt" is actually put in the Launch command. Also note that if you have spaces in filepaths the path must be in quotes as shown for launching.

Link to comment
Share on other sites

Today it struck me that perhaps you were trying to make a paragraph listing (all the filenames in one sentence) rather than a line-by-line list. If that was the case it would highlight my comment about describing what you are trying to do.

 

A comment I omitted was that if you want a variable to be blank then you don't set it (you use but never set). If you have an existing variable that has a value such as "this is a string of text" that you want to set to blank, you do not set it to a space. A space is a character just like a, b, c. It may appear as nothing in text but it is a character. The "" that you see many times in other people's code or quoted in the forum is obtained by setting the variable to absolutely nothing. You don't type anything into the Set Value box.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...