0

ときどき、Mac ファイルを USB サム ドライブまたはポータブル外付けハード ドライブに保存して、MS-DOS、Linux、Unix、または Microsoft Windows ユーザーと共有したり、テレビやメディアなどの Apple 以外の製品で使用したりしたいと考えていました。プレーヤー。問題は、MacOS コンピュータに接続されている USB スティックを含むすべてのディスク デバイスに、MacOS コンピュータ上では見えない無数のファイルが MacOS によって配置されることです。これらのファイルは、ファイル名がピリオド「.」で始まるため、Mac では表示されません。または「ドット」文字の後にデバイス上の通常のファイルの名前が続きます (例: .fileFoo は fileFoo を参照して作成されます)。Mac から USB ドライブを取り出し、Apple 以外の製品で使用しようとすると、正しく機能しません。例えば、デバイスがフリーズしたり、使用できない多くのファイルやフォルダーが表示されたりする場合があります。すべての余分な非表示ファイルが自動的に作成されると、ほぼ満杯に近い外付けの MS-DOS、Linux、Windows、または Unix ドライブが Mac コンピュータに接続されたときに異常な動作をする可能性があります。 MacOS の隠しファイル。

これらの問題は、目に見えないすべてのドット ファイルにまで遡ることができました。オンラインでいくつかの解決策を見つけましたが、私が望んでいたことを正確に行うものはなかったため、この問題を解決するためにシェルスクリプトと組み合わせた AppleScript を作成しました。他の人に役立つ場合に備えて、この質問への回答として投稿します。しかし、私の本当の質問は、エラー処理とコメントを使用してこのスクリプトを改善したり、単一のシェル スクリプトまたは AppleScript ですべてを行った代替案を投稿したりしたい人はいますか?

[編集] OK、作成した回答を 8 時間経過するまで投稿できないので、明日投稿します。それまでの間、ここの専門家が何を思いついたかを見るのは楽しいでしょう. :)

4

1 に答える 1

0

上記の質問に対する私の不器用な答えは次のとおりです。主な欠点は、多くのエラー処理やコメントが不足していることと、シェル スクリプトを実行可能にする方法を学ぶ必要がある技術者以外のユーザーにとって複雑なレベルであることです。それがすべて AppleScript で実行できれば、ドットファイルの問題に困惑している幅広いユーザーにとって、はるかに役立つかもしれません。

以下の 2 つのスクリプトと共有した Readme.txt ファイルを次に示します。

            noMacOSdots.app   
-Introduction-

Sometimes you may want to share files with an MS-DOS or Microsoft Windows user, or a non-Apple product such as a TV or media player.  The problem is that all disk devices including USB sticks that have been attached to a MacOS computer or other Apple device will have files placed on them by MacOS that are invisible to MacOS users.  When you then eject the drive from your Apple product and attempt to use it with a non-Apple product, it will not function correctly.  For example, the device may freeze up or list many files and folders that cannot be used.

The purpose of this app is to quickly and easily delete all of those un-needed invisible files placed by MacOS onto non-Apple drives.  It is only useful for drives using the MS-DOS file format when they are to be used in MS-DOS type devices such as non-Apple TVs and music or video players.  It is of no value for any drives, USB sticks, etc. that are using the MacOS file format.  It may in fact cause some damage to such MacOS devices, and should be used with caution only after carefully reading and understanding the directions.

This app will delete hidden MacOS files from some drives attached to the computer on which this app is launched.  Specifically, only drives with volume names that begin with the letters "MS" will be affected.  Others, for example a drive named "InternalHD" will not be affected.  Due to the simple nature of this app it will not give any indication of which files are deleted, or even whether ANY files were deleted.  Since the app is free and the source code is included, you are free to modify and improve it if you have the time and skills.

IMPORTANT: Before using this app be sure that there are no MacOS devices attached to the Mac on which you run this app with volume names that begin with the letters "MS" (for example, a MacOS USB stick named "MS Smith").  Any such devices will have all hidden MacOS files that begin with a period "." deleted, and that may cause some problems in using those devices.  By using the app you assume all responsibility for any problems that may arise.

-Installation-
1. If you have the file named noMacOSdots.zip, place it in the Utlities folder inside your Applications folder, then double-click it to unzip it.
2. Move the two noMacOSdots files ("noMacOSdots.app" & "noMacOSdots.sh") from the noMacOSdots folder created by unzip, into the Utilities folder leaving this "-ReadMe.txt" file behind.
  NOTE: This app will only function when BOTH of those files are in the Applications/Utilities folder.
3. The app and support file are now installed in your Applications/Utilities folder, and if desired you can drag noMacOSdots.app into the Dock to create a shortcut for it.
4. Launch noMacOSdots.app and follow the on-screen directions carefully.

-Directions-
If you have MS-DOS format USB sticks or other drives used on a MacOS computer that you wish to clean up for use in MS-DOS computers or devices like TVs and games, follow these steps:
    1. Ensure that the external drive's MS-DOS volume name begins with the letters "MS" (for example, you might name a USB stick "MS-USB4G").
    2. Ensure that names of all attached MacOS drives do NOT begin with "MS" to avoid problems (for example, if your Mac's hard drive is named "Ms Smith" it could be damaged by this app).
    3. Launch noMacOSdots.app and click the "OK" button when prompted.
    4. Immediately eject all MS-DOS format external drives after this app displays a "Done" notice, to prevent MacOS from installing new hidden files on the MS-DOS drive.

シェル スクリプトを呼び出すために作成した単純な AppleScript を次に示します (コンパイル済みの「アプリ」バージョンを使用します)。

tell application "Finder"
    display dialog "                -ATTENTION-
This app will delete hidden MacOS files from all attached drives that begin with the letters 'MS'  and is only useful for drives using the MS-DOS file format when they are to be used in MS-DOS type devices such as non-Apple TVs and music or video players.

If you have MS-DOS USB sticks or other drives used on a MacOS computer that you wish to clean up for use in MS-DOS computers or devices like TVs and games, follow these steps:
    1. Ensure that the external drive's volume name begins with the letters 'MS' (example: a USB stick named 'MS-USB4G').
    2. Ensure that the names of all attached MacOS format drives do NOT begin with the letters 'MS' to avoid possibly damaging them (example: a disk named 'Ms Smith'). 
    3. Launch this app and click the 'OK' button when prompted.
    4. Immediately eject all MS-DOS format external drives after this app displays a 'Done' notice, to prevent MacOS from installing new hidden files on the MS-DOS drive.

If you understand and have performed the above steps, click the 'OK' button now to continue.
    NOTE: All hidden MacOS files will be deleted 
    from attached drives with the letters 'MS' at 
    the start of their volume names.

To abort this app now and take no action on any files or drives, just click the 'Cancel' button." buttons {"OK", "Cancel"} default button 2
    set junk to do shell script "/Applications/Utilities/noMacOSdots.sh &> /dev/null"
    display dialog "                -DONE-  
MacOS hidden files deleted from any attached volumes with 'MS' at the start of their names.

Eject MS-DOS drives immediately after exiting this app, or MacOS may create hidden files on them." buttons {"OK"} default button 1
end tell

最後に、上記の 2 つのファイルに対応するシェル スクリプトを次に示します。

#/Applications/Utilities/noMacOSdots.sh
echo ""
echo ""
    echo "  **WARNING: Deleting hidden MacOS files on attached volume(s) whose names begin with 'MS'**"
echo ""
echo "Running dot_clean to save some MacOS info on selected drives..."
    dot_clean -m --keep=mostrecent /Volumes/MS*
echo ""
echo "Deleting MacOS dot files on selected drives..."
    find /Volumes/MS* -depth -name "\.*" -exec rm -rf {} \;
echo ""
echo "EJECT all selected drives NOW to prevent MacOS adding new dotfiles."
echo ""
exit 0
于 2013-09-10T17:47:05.017 に答える