[Mac] ファイルの複製で _v2、_v3・・・と末尾に付ける

Mac では、Finder で Cmd + d でファイルが複製される。複製すると、複製されたファイルのファイル名の末尾に「のコピー」と付く。私は英語版で Mac を使っているので「 copy」(copy の前に半角スペースあり)が付く。

test copy.txt
test copy 2.txt
test copy 3.txt
test copy 4.txt

ちなみに、もう一つファイルを複製する方法は、オプションキーを押しながら同じディレクトリにドラッグアンドドロップする。すると以下のように半角スペースで連番となる。

test 2.txt
test 3.txt
test 4.txt
test 5.txt

以下のページでは「のコピー」ではなく「-v2」とする方法が紹介されている。

MojaveのFinderでファイル複製時に「~のコピー」ではなく「v2」になるようにする方法 | jittodesign blog
https://jittodesign.org/finder-14060/

これを Hackintosh でもやってみた。さらに私は英語版なので少し上記サイトとは設定が変わるし、他にも少し変えている。

(1)まずは SIP(システム整合性保護機構)をオフにする必要がある。でないと、以降のシステムファイルの編集ができないからだ。

現在の SIP の状態は Terminal で以下のコマンドで確認できる。確かに enabled になっている。

$ csrutil status

System Integrity Protection status: enabled (Custom Configuration).

Configuration:  
Apple Internal: disabled  
Kext Signing: disabled  
Filesystem Protections: disabled  
Debugging Restrictions: disabled  
DTrace Restrictions: disabled  
NVRAM Protections: disabled  
BaseSystem Verification: disabled

This is an unsupported configuration, likely to break in the future and leave your machine in an unknown state.

通常の Mac ならリカバリーモードで起動して Terminal で $ csruitl disable を実行することで SIP を無効化できる。

Hackintosh の場合は、EFI>CLOVER>config.plist を編集する。そのためには Clover Configurator で、Rt Variable>CsrActiveConfig を 0x67 にし、再起動。

これで再び SIP の状態を確認すると、diabled に変わった。

$ csrutil status

System Integrity Protection status: disabled.

(2)設定ファイルを Users>[ユーザー名] ディレクトリにコピーする(日本語版 Mac では English.lproj が Japanese.lproj となる)(ここを作業ディレクトリとする)。

$ cp /System/Library/CoreServices/Finder.app/Contents/Resources/English.lproj/Localizable.strings ~/Localizable.strings

(3)ファイルを復号化する。

$plutil -convert xml1 ~/Localizable.strings

(4)テキストエディットで開く。

$open -e ~/Localizable.strings

(5)以下のように変更(N4_V1 を検索すると該当箇所がすぐ見つかる)。保存してテキストエディットを終了する。

変更前:

<key>N4_V1</key>  
<string>^=1 copy</string>  
<key>N4_V2</key>  
<string>^=1 copy ^=0</string>

変更後:

<key>N4_V1</key>  
<string>^=1_v2</string>  
<key>N4_V2</key>  
<string>^=1_v^=0</string>

(6)ファイルの復号化。

$ plutil -convert binary1 ~/Localizable.strings

(7)設定の適用(日本語版 Mac では English.lproj が Japanese.lproj となる)。

$ sudo cp ~/Localizable.strings /System/Library/CoreServices/Finder.app/Contents/Resources/English.lproj/Localizable.strings

(8)Finder を再起動。

$ killall Finder

これで例えば test.txt を Cmd + d で複製するたびに以下のようにファイルが作成されるようになった。

test_v2.txt
test_v3.txt
test_v4.txt
test_v5.txt

参考:
Enable & Disable System Integrity Protection (SIP) on a Hackintosh | Hackintosher
https://hackintosher.com/forums/thread/enable-disable-system-integrity-protection-sip-on-a-hackintosh.53/

SIP システム整合性保護機構 – Boot macOS
https://bootmacos.com/entry/2017/09/12/190025

Finderでファイルを複製するときに「のコピー」でなく「v2」となるように変更する – DTP Transit
https://www.dtp-transit.jp/apple/mac-os-x/post_1922.html

OS X Finder->File->Duplicate (⌘ D) Name Suffix – Thundercloud Consulting, LLC
http://www.thundercloudconsulting.com/tn040/