I'm new to MacroDroid and have no coding experience.
I am trying to do something that I thought would be incredibly easy, but which has tuned out to be a multi-day nightmare.
I have a list of various folders that I want to delete periodically using an Action. I created a delete folder action for each individual folder (about 8 of them) and then assigned the desired Trigger to fire off these actions. This worked fine, except for the fact that once the folders have been deleted, the next time the Action is run I get bombarded with errors saying "Please reconfigure the file path to an accessible location on your device". These errors not only show as notifications, but also on the Actions themselves in the action list.
I thought an easy way to fix this would be to add an "If folder exists/does not exist" condition (which I assumed would be an option or checkbox somewhere) but I could find no such option anywhere. After trawling various sites and web searches I decided to try gibing this AI thing a go. The AI said that MacroDroid has a "File/Folder Exists" action and trigger, and then it gave step-by-step instructions on how to construct the macro. The only problem is that there is no such action in MacroDroid (at least as far as I can see).
The lack of this action seems to be borne out by my search on this forum, which turned up only one result in which a Bash script work-around had to be used simply to check if a folder existed or not. The instructions in that post were vague (it just said 'use a variable') which was not much help to me as a noob.
I ended up going back to AI after hours of further searching on how to do this.
AI suggested that I create a shell script with the following command:
Then add a Set Variable.
It got confusing here because at first it said just assign the variable as 'True' (so presumably Boolean) but then it later said use a String for the variable, but I didn't know whether that variable should contain the text to match (i.e. "Directory exists") or whether the string "True" would be returned if the previous shell command had echoed some output.
Here's what AI said:
This all made sense to me "logically" (bearing in mind that I have no coding or MacroDroid experience) but needless to say it didn't work. I tested by assigning a notification action instead of the folder delete action, but the notification was always triggered regardless of whether the folder in question existed or not.
I even tried using a script to do the folder deletion and just call the whole deletion process from a script action, but that didn't work either, and I don't like that clunky work-around because I can't easily toggle individual folder delete actions on an off as needed (which is easy to do if the delete actions are in the MacroDroid GUI, because you can just tap to disable individual actions, and then re-enable them just as easily). However, if using a script to do the deletion then you'd have to keep opening the script to comment out or delete specific paths (which could easily lead to breaking the script if you even slightly mess up, which is especially likely when trying to edit blocks of script text on a small screen like a phone).
In this particular instance I don't actually care whether the folders exist or not (if there's no folder to delete then that is not an issue). I only resorted to this method of folder-checking in the absence of any native means to stop MacroDoid throwing a total fit just because the Action path does not currently exist at certain points in time.
Any help with the above issue (that preferably stays within the MacroDroud GUI wherever feasible / possible) would be very much appreciated. Thanks.
I am trying to do something that I thought would be incredibly easy, but which has tuned out to be a multi-day nightmare.
I have a list of various folders that I want to delete periodically using an Action. I created a delete folder action for each individual folder (about 8 of them) and then assigned the desired Trigger to fire off these actions. This worked fine, except for the fact that once the folders have been deleted, the next time the Action is run I get bombarded with errors saying "Please reconfigure the file path to an accessible location on your device". These errors not only show as notifications, but also on the Actions themselves in the action list.
I thought an easy way to fix this would be to add an "If folder exists/does not exist" condition (which I assumed would be an option or checkbox somewhere) but I could find no such option anywhere. After trawling various sites and web searches I decided to try gibing this AI thing a go. The AI said that MacroDroid has a "File/Folder Exists" action and trigger, and then it gave step-by-step instructions on how to construct the macro. The only problem is that there is no such action in MacroDroid (at least as far as I can see).
The lack of this action seems to be borne out by my search on this forum, which turned up only one result in which a Bash script work-around had to be used simply to check if a folder existed or not. The instructions in that post were vague (it just said 'use a variable') which was not much help to me as a noob.
I ended up going back to AI after hours of further searching on how to do this.
AI suggested that I create a shell script with the following command:
Code:
[ -d /path/to/directory ] && echo "Directory exists"
Then add a Set Variable.
It got confusing here because at first it said just assign the variable as 'True' (so presumably Boolean) but then it later said use a String for the variable, but I didn't know whether that variable should contain the text to match (i.e. "Directory exists") or whether the string "True" would be returned if the previous shell command had echoed some output.
Here's what AI said:
- In the "Variable Set" action, set the variable name to "Folder Exists".
- In the "Value" field of the "Variable Set" action, enter the following expression: if([rd] = "Directory exists", "true", "false").
- In this expression, [rd] is a special MacroDroid variable that contains the output of the last "Run Shell Command" action. The expression checks if [rd] is equal to the string "Directory exists". If it is, the expression returns the string "true". If it is not, the expression returns the string "false".
- Finally, use the "Constraint" feature to check the value of the "Folder Exists" variable before running the following actions to ensure that they are only taken if the directory exists.
This all made sense to me "logically" (bearing in mind that I have no coding or MacroDroid experience) but needless to say it didn't work. I tested by assigning a notification action instead of the folder delete action, but the notification was always triggered regardless of whether the folder in question existed or not.
I even tried using a script to do the folder deletion and just call the whole deletion process from a script action, but that didn't work either, and I don't like that clunky work-around because I can't easily toggle individual folder delete actions on an off as needed (which is easy to do if the delete actions are in the MacroDroid GUI, because you can just tap to disable individual actions, and then re-enable them just as easily). However, if using a script to do the deletion then you'd have to keep opening the script to comment out or delete specific paths (which could easily lead to breaking the script if you even slightly mess up, which is especially likely when trying to edit blocks of script text on a small screen like a phone).
In this particular instance I don't actually care whether the folders exist or not (if there's no folder to delete then that is not an issue). I only resorted to this method of folder-checking in the absence of any native means to stop MacroDoid throwing a total fit just because the Action path does not currently exist at certain points in time.
Any help with the above issue (that preferably stays within the MacroDroud GUI wherever feasible / possible) would be very much appreciated. Thanks.
Last edited: