Skip to main content
Question

Delete File by File Extension


Forum|alt.badge.img+3
  • New Contributor
  • 2 replies

Hey Jamf Nation -

Apologies if this has been posted before.

Is there an easy way to delete a file with a specific extension, found in the logged in user's profile using JAMF? For example, any file with the extension of .DOC, I'd like for JAMF to find it and delete it. Is that possible?

3 replies

Forum|alt.badge.img+12
  • Valued Contributor
  • 191 replies
  • March 20, 2018

You'd probably have to make a script to do that, but you'd be using wildcards and that can be risky.


Forum|alt.badge.img+8
  • Valued Contributor
  • 87 replies
  • March 20, 2018

I've used this to find files with .doc extension. I'm assuming you can add a for loop or something so that each entry will be deleted.

Please test, test, test before putting on JAMF Pro and run it with Check-In policy.

#!/bin/sh

loggedinuser=$(stat -f%SU /dev/console)

sudo find /Users/$loggedinuser/ -type f -name "*.doc"

Forum|alt.badge.img+3
  • Author
  • New Contributor
  • 2 replies
  • March 20, 2018

Thank you sooooo much! So, essentially, that script would find any files with .DOC extension and delete them?

My example was for .DOC, but I'm actually trying to delete Outlook archives/exports and didn't find a way to prevent staff from exporting from Outlook. This would save in .OLM file. So, in theory, I can substitute .DOC with .OLM and test, test, test.


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings