How do I delete macOS compressed hidden files in the package?

How do I delete macOS compressed hidden files in the package? In operation, compressed packed files is indispensable for a job. In order to avoid damage and missing files, we usually macOS system, multiple files or folders compressed for transmission, we generally use the visit to compression of (Finder) right-click menu, very convenient. However, there is another issue which is compressed file contains __MACOSX, .DS_Store macOS system and other hidden files.

13151818_6c303aa907.jpeg

If it is carried out on macOS system to extract or to view these files are hidden, there is no impact. But if the user is sent to the Windows system, then unzip the files will be displayed, it may cause other side of doubt, cause unnecessary trouble.

13150801_d9e50e4ad5.png

Hidden files in the compressed file

In fact, we can use the built-in automation software macOS automatic operation (Automator) to solve this problem.

Solution
here can be used to extract the Oka experts, unzip double-click installation.

Then, if you need to remove hidden files compressed Zip file, right-click menu directly choose their services in the "purification Zip compressed file" can be. When processing is complete, also issued a reminder.

13151153_c9ff4a2b93.gif

Show

principle

After using the "automatic operation" open, you can see its contents is not complicated. First, the scope of its work is set in the "visit of a file or folder", so that only appear in the menu of these locations. Of course, you can also be modified according to their needs. Specific document processing operations are carried out by Shell script. After processing is complete notification reminders.

13151320_8172c91a2c.png

Internal Process

Shell script reads as follows, is also used macOS own command, do not need to install additional software and without network support multi-file batch operation. The general process of the script is: each of the selected file to determine whether to compress files to zip, if it is then purification operation.


# 循环处理选择的多个文件
for f in "$@"
do
# 获取文件类型,以确保是 Zip 压缩文件
fileType=$(file -bI "$f")
if [[ $fileType =~ "application/zip*" ]]; then
# 删除 __MACOSX 与 .DS_Store 文件
zip -d "$f" \*__MACOSX\* || true
zip -d "$f" \*.DS_Store\* || true
fi
done


Conclusion
In fact, __ MACOSX and .DS_Store macOS system is used to save the folder a custom icon, such as the location where the file metadata information. If a Zip file is always used on macOS, these files will not show up, do not remove these files.

You can also use Keka, BetterZip compression software, etc., they all have the exclusion __MACOSX and .DS_Store and other documents when compressed.


Guess you like

Origin blog.51cto.com/14370425/2466396