Sử dụng lệnh terminal dưới đây để nén thư mục mà không kèm theo file .DS_Store và __MACOSX:
zip -r dir.zip . -x '**/.*' -x '**/__MACOSX'
Trong đó:
dir.zip là tên file nén –> bạn có thể thay đổi theo yêu cầu.
-x là loại trừ các file có tên tương tự với mẫu tên phía sau:
‘*/.‘ là để loại trừ thư mục .DS_Store
‘**/_MACOSX’ là để loại trừ thư mục _MACOSX
Một số lệnh sử dụng tương ứng trong một số trường hợp:
zip -r "$(basename "$PWD").zip" . -x '.*' -x '__MACOSX' -x 'Settings.cfg' zip -r "$(basename "$PWD").zip" */ -x '.*' -x '__MACOSX' -x 'Settings.cfg'
zip -r: Recursive zipping
“$(basename “$PWD”).zip”: Creates zip file named after current directory
*/: Only includes directories (subfolders) and their contents, excluding root files
Exclusions:
-x ‘.*’: Excludes hidden files/folders
-x ‘__MACOSX’: Excludes macOS metadata
-x ‘Settings.cfg’: Excludes specific config file
Tham khảo: https://apple.stackexchange.com/questions/239578/compress-without-ds-store-and-macosx
[đăng nhập để xem được thêm các nội dung ẩn]
