I want to create one relevance to read only specific file on the given location, if any other files are available on that location, then the value should be false as per my below relevance but i got true only & there are three files available (one file of that location is not mentioned in the below relevance but still the relevance is showing True).
if (exists folder "\AppData\Microsoft\Teams\Backgrounds" whose (exists file ("abc.png";"xyz.png") of it) of folders of folders "c:\users") then "true" else "false"
Iâm not sure that I follow the logic youâre trying to implement.
Youâd like to read a specific file at a given locationâŚwhat criteria should be used to identify the file(s) and how do you want to handle cases where multiple files meet the criteria? Do you only want it to return âTrueâ if there is only 1 file of a list of files you specify by name? What about if no files match the criteria?
Also, is the folder path youâre specifying above correct? Should there not be an additional folder between âAppDataâ and âMicrosoftâ (such as Local or Roaming)?
Perhaps the following may give you some ideas in the interim:
(number of files ("abc.png";"xyz.png") of folders "\AppData\Roaming\Microsoft\Teams\Backgrounds" of folders of folders "C:\Users") = 1
You might also consider this if you want to ensure that both files exist. (edited to add the local folder at Aramâs suggestion)
exists folder "\AppData\local\Microsoft\Teams\Backgrounds" whose (exists file "abc.png" of it and exists file "xyz.png" of it) of folders of folders "c:\users"
Actually, I have shared the location as an example purpose did not share the accurate location and I did not face any problem in location (pls ignore that). And my query is I have x no. files in a location, but I need to create one relevance where I need to check only specific files, and if there are any other files (expect that specific files) are available in that location that relevance should be show False but, in my case, it is showing True only.
So I think you want that: the 2 files must both exist in the location, and that no other files exist in the location?
try this one:
exists folder "\AppData\local\Microsoft\Teams\Backgrounds" whose (exists file "abc.png" of it and exists file "xyz.png" of it and not exists files whose (name of it as lowercase is contained by set of ("abc.png";"xyz.png")) of it) of folders of folders "c:\users"
First, I would recommend creating an analysis property that returns all files that meet the criteria on the system to investigate the situation and help test the relevance.
pathnames of files whose(name of it as lowercase ends with ".png") of folders "AppData\Microsoft\Teams\Backgrounds" of folders of folders "c:\users"
Remember, what this returns depends on how many users are local to any particular system that have Microsoft Teams Backgrounds, not just how many backgrounds are defined for any single user, so pay attention to the C:\Users\USERNAME section of the pathname results.
Then it sounds like you want exactly 1 of a set of possible files to exist? Iâm still a little unclear on this. Can you take a screenshot of file explorer showing an example of the folder with an example of what you DO want and another of what you DO NOT want to compare? Maybe more than one example of what you DO want if there are multiple options?
It sounds like this is what you are asking for though:
( 1 = number of files whose(name of it as lowercase ends with ".png") of folders "AppData\Microsoft\Teams\Backgrounds" of it ) of folders of folders "c:\users"
WARNING: this is not valid applicability relevance, because it will return TRUE; FALSE; FALSE depending on how many users are present on the system that either meet or do not meet the criteria. So you would still need to put this in an analysis property to measure how many user folders meet or do not meet the criteria.
Then the question becomes⌠do you want applicability relevance to be TRUE if any user folder does not meet the criteria? or do you want it to be TRUE only if all user folders are missing the criteria? What is the desired outcome?
The way I would generally do this is I would write the applicability relevance such that it returns TRUE if any user folder does NOT meet the desired criteria, and then I would run an action that would address the lack of desired state on each user folder that is missing something. To restate this a bit more clearly: I generally want the applicability relevance to return FALSE if all user folders have the desired state. I want the applicability relevance to return TRUE if any user folder does not have the desired state.
Even if every computer should have exactly 1 user, you will write better / more flexible relevance if you always assume there are multiple.