Skip to content

It finds all .DS_Store files in the current directory and deletes them.

License

Notifications You must be signed in to change notification settings

c4arl0s/rm-dot-DS_Store-files-recursively

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 

Repository files navigation

Remove .DS_Store File Recursively Script

It removes the annoying .DS_Store files in the current directory.

How to use it ?

You just placed in the directory you need to remove those files, then execute the script:

$ ./rmDotDSStoreScript.sh

Code

#!/bin/bash
#
# it finds all .DS_Store files in the current directory and deletes them

readonly ds_store_file_name='.DS_Store'
success_msg="🟢 Files: ${ds_store_file_name} were deleted"
error_msg="${ds_store_file_name} files were not found"

#######################################
# A function to print out error messages 
# Globals:
#   
# Arguments:
#   None
#######################################
function error() {
  echo "[🔴 $(date +'%Y-%m-%dT%H:%M:%S%z')]: $*" >&2
}

store_files=$(find . -name "*" -type f \
  | sort -n -r \
  | grep ${ds_store_file_name} \
  | tee /dev/tty)

[ -n "${store_files}" ] \
  || { error ${error_msg}; exit 1; }

echo ${store_files} \
  | sort -n -r \
  | while read store_file; do
      rm ${store_file} 
      echo "${store_file} were deleted" 
    done

About

It finds all .DS_Store files in the current directory and deletes them.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages