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.

  • 2
    In bash, rm ._* <-- Sorcery! – Parthian Shot Jul 29 '15 at 18:07
  • @ParthianShot Please post answers as answers, not as comments. – Gilles 'SO- stop being evil' Jul 29 '15 at 23:05
  • @Gilles Oh, alright... – Parthian Shot Jul 30 '15 at 0:02
  • Why is my question down voted? – uday Jul 30 '15 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 '15 at 8:30

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
  mv -- "$line" "${line:2}"
  • Note that your answer won't work if filename contains newline, or too many files. – cuonglm Jul 30 '15 at 1:52
  • Note: renaming a ._file to file will overwrite the data fork in AppleDoubleFormat files, rendering the file unless. – fd0 Jul 30 '15 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'). – Parthian Shot Jul 30 '15 at 23:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.