MacResource
How do I delete all hidden files from a folder in the Terminal? - Printable Version

+- MacResource (https://forums.macresource.com)
+-- Forum: My Category (https://forums.macresource.com/forumdisplay.php?fid=1)
+--- Forum: Tips and Deals (https://forums.macresource.com/forumdisplay.php?fid=3)
+--- Thread: How do I delete all hidden files from a folder in the Terminal? (/showthread.php?tid=181617)



How do I delete all hidden files from a folder in the Terminal? - freeradical - 07-31-2015

When I copy a bunch of jpg's to a flash drive, or an SD card, I also seem to create a bunch of hidden files. These are all small files of 4096 bytes.

These devices are formatted MS-DOS (FAT32)

For example, if I copy a jpg with the filename of IMG_3232.jpg, I also end up with a hidden file called ._IMG_3232.jpg in the same directory. I can see this when I use the ls -al command at the terminal after I've navigated to the folder with the images I've copied. These hidden files cause serious problems when trying to run a slideshow on my television using the TV's SD card input, or my iDevice with the flash drive.

Is there a way to batch remove all of these hidden files (without deleting the real files) using some sort of wildcard in the terminal?



For example, if I do this command:

rm *.jpg

I will delete all jpg files in a directory.



Would something like:

rm *._

do the trick?


Re: How do I delete all hidden files from a folder in the Terminal? - wave rider - 07-31-2015

Not sure about terminal, use to be able to search for hidden files in the finder using the option key to reveal that choice.

=wr=


Re: How do I delete all hidden files from a folder in the Terminal? - TheCaber - 07-31-2015

rm ._*.jpg  
will do what you want . You don't want to remove all hidden files in the directory , just those that are related to the image files .

If you want to remove all the FAT hidden property files in the directory , use
rm ._*



Re: How do I delete all hidden files from a folder in the Terminal? - Onamuji - 07-31-2015

In the Terminal:

dot_clean /Volumes/[name of FAT vol]


Re: How do I delete all hidden files from a folder in the Terminal? - freeradical - 07-31-2015

TheCaber wrote:
rm ._*.jpg  
will do what you want . You don't want to remove all hidden files in the directory , just those that are related to the image files .

If you want to remove all the FAT hidden property files in the directory , use
rm ._*


Thanks!

This worked like a champ:

rm ._*.jpg


Of course I also had to run:

rm ._*.JPG

:-)