How can I avoid it?
The error message stop the flow, it's not just a "warning" message.
The file I'm trying to delete sometimes exist and sometimes don't.
It's hard for me to evaluate the presence of that file.
How can I manage it?
Really thank you ...
Error when try to delete a file wich not exist
Moderator: Martin
Re: Error when try to delete a file wich not exist
Hi,
You can either use a condition Expression: existsFile(pathToFile) to check if the file exists or use action Init Variables File Info to test it and store the result in variable file_exists.
Alternatively you can also catch the exception. To do this, append an action like Notification on Screen to the action that produces the exception. Select the connection between the two actions, press edit and change the type to 'Exception'. The notification-action will only be executed when the first action produces an exception. Automagic will not stop the flow in this case and will not show an error by itself.
Regards,
Martin
You can either use a condition Expression: existsFile(pathToFile) to check if the file exists or use action Init Variables File Info to test it and store the result in variable file_exists.
Alternatively you can also catch the exception. To do this, append an action like Notification on Screen to the action that produces the exception. Select the connection between the two actions, press edit and change the type to 'Exception'. The notification-action will only be executed when the first action produces an exception. Automagic will not stop the flow in this case and will not show an error by itself.
Regards,
Martin
Re: Error when try to delete a file wich not exist
The second way (exception) works for me.
Anyway I tried the first too but I can't wrte the Expression correctly (as usual),
the expression line is :
existsFile(/storage/extSdCard/.dir/file.txt)
and it's wrong.
but the string "/storage/extSdCard/.dir/file.txt" it's the same that I use in the other flow to write that file (and of course it works).
How should I write the Expression?
Thank you!!
Anyway I tried the first too but I can't wrte the Expression correctly (as usual),
the expression line is :
existsFile(/storage/extSdCard/.dir/file.txt)
and it's wrong.
but the string "/storage/extSdCard/.dir/file.txt" it's the same that I use in the other flow to write that file (and of course it works).
How should I write the Expression?
Thank you!!
Re: Error when try to delete a file wich not exist
Hi,
You have to surround the path with double quotes since the value is a string:
existsFile("/storage/extSdCard/.dir/file.txt")
or you could assign the path to a variable first:
path = "/storage/extSdCard/.dir/file.txt";
existsFile(path)
Regards,
Martin
You have to surround the path with double quotes since the value is a string:
existsFile("/storage/extSdCard/.dir/file.txt")
or you could assign the path to a variable first:
path = "/storage/extSdCard/.dir/file.txt";
existsFile(path)
Regards,
Martin
Re: Error when try to delete a file wich not exist
Thank youuu!!!
Re: Error when try to delete a file wich not exist
Hi !
I resume this old post because I need to check a condition before to move some files :
the condition should be if almost one of file with a specific extension (for example "txt") exist,
then move all the files to another directory.
So I've tried this way
existsFile("/storage/extSdCard/.dir/*.txt")
but the "*" seems not working.
How can I solve it?
Thank you .
I resume this old post because I need to check a condition before to move some files :
the condition should be if almost one of file with a specific extension (for example "txt") exist,
then move all the files to another directory.
So I've tried this way
existsFile("/storage/extSdCard/.dir/*.txt")
but the "*" seems not working.
How can I solve it?
Thank you .
Re: Error when try to delete a file wich not exist
AFAIK, you can't use wild card/pattern at that function.
You should use Init variable File list, match every file with .txt (replace the path as needed)
File Pattern : /storage/extSdCard/.dir/*.txt
and check using expression if {files} is empty
Expression : isEmpty(files)
Then move the files if false (false mean .txt files exist)
You should use Init variable File list, match every file with .txt (replace the path as needed)
File Pattern : /storage/extSdCard/.dir/*.txt
and check using expression if {files} is empty
Expression : isEmpty(files)
Then move the files if false (false mean .txt files exist)
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.
Re: Error when try to delete a file wich not exist
Yes I've done !!!
Really thank you!!!
Really thank you!!!