I have a MacAir running El Capitan with all updates. I use a USB stick to move movies from Mac to Samsung Smart TV. The TV writes a hidden file " .device_info_*** " (long abstract filename). This file keeps details of movie folders in it... but does not update. So when I delete a movie... the folder stays hidden on the stick in this file and shows again when connected to the TV. I have created a work around by showing hidden files and deleting this file... the old folder info disappears when viewing on the TV and the TV writes a new file when USB is reinserted. But the whole process starts all over again.

I want to have an auto script that deletes the .device_info_*** file every time the USB is connected to my MacAir - without any user interface or questions about "are you sure, etc" . The asterisks in my example are wildcards because the filenames created are different every time (after the .device_info_ part of the name).

What script would do this? And can wild cards be used as part of the filename in the script?

I am not a script writer but am pretty savvy.

  • I also empty Trash of course... and run Clean My Mac & Clean My Drive (which does find garbage) but still the folders hide in the .device_info_* file. Commented Jan 2, 2016 at 12:18

1 Answer 1


Here's a Keyboard Maestro script that deletes a file when a partition is mounted:


If you want wildcards, it might be more useful to use a script action with rm:

rm /Volumes/volumename/.file*
  • Thank you. I will need the use of wildcards because the Samsung TV sets a new filename every time... the beginning is the same: .device_info_ ...followed by an alpha numeric sequence - this is the current one .device_info_1db59465-b03a-41e6-862a-f342d49e84ff Commented Jan 2, 2016 at 13:55
  • Also - will this auto execute when the USB is inserted/connected to the Mac? Commented Jan 2, 2016 at 13:56
  • I just tried the Terminal Command rm /Volumes/volumename/.device_info_* Commented Jan 2, 2016 at 14:07
  • and it came back that file does not exist... probably because it is hidden (although I can see it with hidden files set to show). Thanks again. Commented Jan 2, 2016 at 14:08
  • @ElMarinero Yes, it will auto execute on mounting. Terminal will always be able to see/delete hidden files because there's not really as such in the shell (it's just how Finder represents the file). Make sure the path is correct and drag the file into Terminal to show the path, escaping spaces as necessary.
    – grg
    Commented Jan 2, 2016 at 14:11

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .