Jump to content
Macro Express Forums

How to know if a folder is empty ?


Recommended Posts

Hi forum, 


I post my first message on this forum.....I just bought Macro Express Pro 6 yesterday.

 

Is there a way to check if the folder donwload is empty or not 

 

if not empty, to simulate the Ctrl +A  

 

and then Enter

 

thanks fro your answer

Link to comment
Share on other sites

Something like this should work.  It will be a learning experience to look up all these commands and enter them with the correct options. 

 

Actually this is overkill -- you don't have to get ALL the file names to know that the folder is not empty.  As soon as one file name is returned from the Repeat with Folder command, you could "Repeat Exit" from the loop and do the typing. 
 

//  
Variable Set Integer %counter% to 0              // initialize counter
Repeat with Folder c:\folder_name                // return names of all files in folder
  Variable Modify Integer %counter%: Increment   // increment counter for each file name
End Repeat
//  
If Variable %counter% Is Greater Than "0"          // if folder is not empty
  Text Type (Simulate Keystrokes): <CTRLD>a<CTRLU> // type ctrl + a
  Delay: 500 milliseconds                          // delay 1/2 second
  Text Type (Simulate Keystrokes): <ENTER>         // type ENTER
End If
//  

 

  • Like 1
Link to comment
Share on other sites

Thanks  a lot for your answer, that helps me a lot to do what I want

 

here is my final code

 

<VARIABLE SET INTEGER Option="\x00" Destination="%Counter%" Value="0" _COMMENT="Nombre de fichiers dans téléchargements\r\n"/>
<REPEAT WITH FOLDER Path="C:\\Users\\hfaureis\\Downloads" OnlyFiles="TRUE" Destination="%Result%" FullPath="FALSE" ProcSubfolders="FALSE"/>
<VARIABLE MODIFY INTEGER Option="\x07" Destination="%Counter%"/>
<END REPEAT/>
<MESSAGEBOX Caption="sq" Message="%Counter%" Icon="0"/>
<DELAY Flags="\x02" Time="500"/>
<IF VARIABLE Variable="%Counter%" Condition="\x05" Value="2" IgnoreCase="FALSE"/>
<MESSAGEBOX Caption="Répertoire Téléchargement" Message="Répertoire déjà vide" Icon="0" _COMMENT="Répertoire déjà vide\r\n"/>
<ELSE/>
<MESSAGEBOX Caption="Répertoire Téléchargement" Message="On vide le répertoire" Icon="0" _COMMENT="On vide le répertoire\r\n"/>
<OPEN FOLDER Path="C:\\Users\\hfaureis\\Downloads" _COMMENT="On ouvre le répertoire download\r\n"/>
<DELAY Flags="\x01" Time="1"/>
<WINDOW MAXIMIZE Option="\x00" Partial="TRUE" Wildcards="FALSE" _IGNORE="0x0006"/>
<MOUSE MOVE Option="\x01" X="949" Y="304" _PROMPT="0x000A"/>
<DELAY Flags="\x01" Time="1"/>
<TEXT TYPE Action="0" Text="<CTRLD>a<CTRLU>" _COMMENT="On simule Ctrl + A"/>
<DELAY Flags="\x01" Time="1"/>
<MOUSE MOVE Option="\x01" X="522" Y="83" _PROMPT="0x000A" _COMMENT="On se deplace sur la croix rouge pour supprimer les fichiers"/>
<DELAY Flags="\x01" Time="1"/>
<MOUSE LEFT CLICK/>
<DELAY Flags="\x01" Time="1"/>
<TEXT TYPE Action="0" Text="<ENTER>" _COMMENT="On confirme l'effacement"/>
<END IF/>

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...