0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

.DS_Storeを一括削除する

Last updated at Posted at 2024-04-30

概要

  • Mac環境で勝手にできたりする.DS_Storeは何か
  • そして、どのように簡単に消せるか

何ものか

まとめ

  • macOSから自動で作られる記録ファイル(基本的にWindowsやLinuxなどの他のOSではないもの)
    • 特定のフォルダ内での表示設定や配置情報を保持するために使用
    • 具体的には、フォルダ内のアイコンの位置やサイズ、表示されるカスタム設定などが含まれる
  • ファイル作成、コピペ、アイコンの配置を変更、表示オプションをカスタマイズしたりするなどで自動で作られる

よくみられる現状

  • リモートリポジトリまで混ざることが頻繁
  • 隠しファイルでもあるので、結構面倒
  • あちこちに隠れているので、一個づつ探して消すのも大変

コード

ターミナルを開き、ディレクトリへ遷移し、以下のコードを入力します。

zsh

find . -name '.DS_Store' -type f -ls -delete


解説

  • find: 探してね
  • .: 現在のディレクトリで
  • -name '.DS_Store': .DS_Storeのファイルを
  • -type f: 対象をファイルとして制限する。ディレクトリや他のフォーマットの場合は対象外になる
  • ls:このコマンドを実行した後、ファイルリストを出力してくれます。省略すれば何も出ません
  • -delete: 消せ!

現在のディレクトリを基準として、配下ディレクトリまで全ての.DS_Storeを探して一括削除するコマンドであります。

zsh, bashなどを使うVSCodeのターミナルでも実行できます。

[1]cd Documents
[2]コマンド入力
[3]大掃除⭐️

image.png

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?