Delete files in a path relative to the current user's home directory

We have a problem with Outlook for Mac, and I’m hoping to use AppleScript to solve it. The problem is that Outlook 2016 doesn’t properly update it’s image cache (where it stores images of contacts).

The fix is to remove the affected cache files. The files are stored in a particular folder, but I don’t want to delete all the files in that folder, just those ending with the string “mydomain.com_LDAP”

I can easily accomplish my goal using a shell script:

[format]rm ~/Library/.miscellaneous subfolders./Outlook/Main\ Profile/Caches/Image\ Cache/*mydomain.com_LDAP[/format]

But I can’t figure out how to accomplish the same thing from AppleScript.

I tried this:
[format]do shell script
“rm ~/‘Library/.miscellaneous subfolders./Outlook/Main Profile/Caches/Image Cache/*mydomain.com_LDAP’”[/format]
But I get “No such file or directory.” I’ve tried a few variations, but nothing works.

Note: I’m not necessarily looking for a solution that uses a shell script. If there’s an easier way, I’m definitely open to it. I just want any solution that works.

You may try :

set theFolder to (path to library folder from user domain as text) & "miscellaneous subfolders.:Outlook:Main:Profile:Caches:Image:Cache:"

tell application "System Events"
	tell folder theFolder
		delete (every file whose name ends with "mydomain.com_LDAP")
	end tell
end tell

Yvan KOENIG running El Capitan 10.11.6 in French (VALLAURIS, France) lundi 25 juillet 2016 18:06:39