-2

I have these files in MAC which have weird ._ character before filenames/folders. Which I want to delete in one shot. Is there a way to do it in commandline?

eg. ._js ._css ._image

if I go into normal image folder. I see another swarm of these files along with the actual files.

5
  • 2
    In bash, rm ._* <-- Sorcery! Jul 29, 2015 at 18:07
  • @ParthianShot Please post answers as answers, not as comments. Jul 29, 2015 at 23:05
  • @Gilles Oh, alright... Jul 30, 2015 at 0:02
  • Why is my question down voted?
    – uday
    Jul 30, 2015 at 0:08
  • I guess it's because they think you shouldn't delete them and over than that you can search for the way to easily.
    – McSinyx
    Jul 30, 2015 at 8:30

1 Answer 1

4

In bash, this will delete everything in the current working directory which has the prefix ._:

rm ._*

If what you actually wanted to do was change their names to a form without the prefix, you can run:

ls ._* | while read line
do
  mv -- "$line" "${line:2}"
done
3
  • Note that your answer won't work if filename contains newline, or too many files.
    – cuonglm
    Jul 30, 2015 at 1:52
  • Note: renaming a ._file to file will overwrite the data fork in AppleDoubleFormat files, rendering the file unless.
    – fd0
    Jul 30, 2015 at 10:04
  • @cuonglm if filename contains newline True. Although, thankfully, I've never run into code in the wild which does that (excepting things I've intentionally written for fun; touch $'\n'). Jul 30, 2015 at 23:46

You must log in to answer this question.

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