__MACOSX 폴더없이 Mac zip 압축?
Mac OSX에서 내장 된 zip 압축기로 파일을 압축하면 압축이 풀린 zip에 "__MACOSX"라는 추가 폴더가 생성됩니다.
이 폴더가 생성되지 않도록 설정을 조정할 수 있습니까? 아니면 타사 압축 도구를 구입해야합니까?
업데이트 : 방금 내 문제를 해결하는 OSX 용 프리웨어 응용 프로그램을 찾았습니다. " YemuZip "
업데이트 2 : YemuZip은 더 이상 프리웨어가 아닙니다.
이 문제가 발생했을 때 명령 줄에서 수행했습니다.
zip file.zip uncompressed
많은 downvotes 후 EDIT : 나는 얼마 전에이 옵션을 사용하고 있었고 어디서 배웠는지 알지 못하므로 더 나은 설명을 줄 수 없습니다. 크리스 존슨의 대답 은 정확하지만 삭제하지는 않습니다. 한 의견에서 알 수 있듯이 압축 파일에서 파일을 제거하는 대신 파일없이 압축하므로 OP가 요구하는 내용이 더 정확합니다. 나도 기억하기 쉽다는 것을 알았습니다.
에 의해 사실 후에 고칠 수 있습니다 zip -d filename.zip __MACOSX/\*
터미널에서 압축하려는 폴더 내부 :
zip -r -X Archive.zip *
-X의 의미 :“_MACOSX”또는“._Filename”과 같은 보이지 않는 Mac 리소스 파일과 .ds 저장 파일을 제외합니다.
참고 : 폴더 및 후속 폴더 트리에서만 작동하며 *와일드 카드 가 있어야합니다 .
이 명령은 나를 위해 그것을했다 :
zip -r Target.zip Source -x "*.DS_Store"
Target.zip작성할 zip 파일입니다. Source압축 할 소스 파일 / 폴더입니다. 그리고 _x매개 변수는 포함하지 않을 파일 / 폴더를 지정합니다. 어떤 이유로 든 위의 방법으로 작동하지 않으면 대신 시도하십시오.
zip -r Target.zip Source -x "*.DS_Store" -x "__MACOSX"
이 Automator Shell Script를 사용하여 문제를 해결하고 있습니다. 상황에 맞는 메뉴 항목으로 표시됩니다 (Finder에 표시되는 파일을 마우스 오른쪽 버튼으로 클릭).
while read -r p; do
zip -d "$p" __MACOSX/\* || true
zip -d "$p" \*/.DS_Store || true
done
- Automator를 사용하여 새 서비스 생성
- "파인더"에서 "파일 및 폴더"를 선택하십시오.
- "쉘 스크립트 동작"추가
원하지 않는 폴더는 다음과 같은 방법으로도 삭제할 수 있습니다.
zip -d filename.zip "__MACOSX*"
나를 위해 가장 잘 작동
zip명령 행 유틸리티는 생성 결코 __MACOSX그냥이 같은 명령을 실행할 수 있도록, 디렉토리 :
zip directory.zip -x \*.DS_Store -r directory
In the output below, a.zip which I created with the zip command line utility does not contain a __MACOSX directory, but a 2.zip which I created from Finder does.
$ touch a
$ xattr -w somekey somevalue a
$ zip a.zip a
adding: a (stored 0%)
$ unzip -l a.zip
Archive: a.zip
Length Date Time Name
-------- ---- ---- ----
0 01-02-16 20:29 a
-------- -------
0 1 file
$ unzip -l a\ 2.zip # I created `a 2.zip` from Finder before this
Archive: a 2.zip
Length Date Time Name
-------- ---- ---- ----
0 01-02-16 20:29 a
0 01-02-16 20:31 __MACOSX/
149 01-02-16 20:29 __MACOSX/._a
-------- -------
149 3 files
-x .DS_Store does not exclude .DS_Store files inside directories but -x \*.DS_Store does.
The top level file of a zip archive with multiple files should usually be a single directory, because if it is not, some unarchiving utilites (like unzip and 7z, but not Archive Utility, The Unarchiver, unar, or dtrx) do not create a containing directory for the files when the archive is extracted, which often makes the files difficult to find, and if multiple archives like that are extracted at the same time, it can be difficult to tell which files belong to which archive.
Archive Utility only creates a __MACOSX directory when you create an archive where at least one file contains metadata such as extended attributes, file flags, or a resource fork. The __MACOSX directory contains AppleDouble files whose filename starts with ._ that are used to store OS X-specific metadata. The zip command line utility discards metadata such as extended attributes, file flags, and resource forks, which also means that metadata such as tags is lost, and that aliases stop working, because the information in an alias file is stored in a resource fork.
Normally you can just discard the OS X-specific metadata, but to see what metadata files contain, you can use xattr -l. xattr also includes resource forks and file flags, because even though they are not actually stored as extended attributes, they can be accessed through the extended attributes interface. Both Archive Utility and the zip command line utility discard ACLs.
zip -r "$destFileName.zip" "$srcFileName" -x "*/\__MACOSX" -x "*/\.*"
-x "*/\__MACOSX": ignore __MACOSX as you mention.-x "*/\.*": ignore any hidden file, such as .DS_Store .- Quote the variable to avoid file if it's named with SPACE.
Also, you can build Automator Service to make it easily to use in Finder. Check link below to see detail if you need.
You can't.
But what you can do is delete those unwanted folders after zipping. Command line zip takes different arguments where one, the -d, is for deleting contents based on a regex. So you can use it like this:
zip -d filename.zip __MACOSX/\*
do not zip any hidden file:
zip newzipname filename.any -x "\.*"
with this question, it should be like:
zip newzipname filename.any -x "\__MACOSX"
It must be said, though, zip command runs in terminal just compressing the file, it does not compress any others. So do this the result is the same:
zip newzipname filename.any
Do you mean the zip command-line tool or the Finder's Compress command?
For zip, you can try the --data-fork option. If that doesn't do it, you might try --no-extra, although that seems to ignore other file metadata that might be valuable, like uid/gid and file times.
For the Finder's Compress command, I don't believe there are any options to control its behavior. It's for the simple case.
The other tool, and maybe the one that the Finder actually uses under the hood, is ditto. With the -c -k options, it creates zip archives. With this tool, you can experiment with --norsrc, --noextattr, --noqtn, --noacl and/or simply leave off the --sequesterRsrc option (which, according to the man page, may be responsible for the __MACOSX subdirectory). Although, perhaps the absence of --sequesterRsrc simply means to use AppleDouble format, which would create ._ files all over the place instead of one __MACOSX directory.
I have a better solution after read all of the existed answers. Everything could done by a workflow in a single right click. NO additional software, NO complicated command line stuffs and NO shell tricks.
The automator workflow:
- Input: files or folders from any application.
- Step 1: Create Archive, the system builtin with default parameters.
Step 2: Run Shell command, with input as parameters. Copy command below.
zip -d "$@" "__MACOSX/*" || truezip -d "$@" "*/.DS_Store" || true
Save it and we are done! Just right click folder or bulk of files and choose workflow from services menu. Archive with no metadata will be created alongside.
This is how i avoid the __MACOSX directory when compress files with tar command:
$ cd dir-you-want-to-archive $ find . | xargs xattr -l # <- list all files with special xattr attributes ... ./conf/clamav: com.apple.quarantine: 0083;5a9018b1;Safari;9DCAFF33-C7F5-4848-9A87-5E061E5E2D55 ./conf/global: com.apple.quarantine: 0083;5a9018b1;Safari;9DCAFF33-C7F5-4848-9A87-5E061E5E2D55 ./conf/web_server: com.apple.quarantine: 0083;5a9018b1;Safari;9DCAFF33-C7F5-4848-9A87-5E061E5E2D55
Delete the attribute first:
find . | xargs xattr -d com.apple.quarantine
find . | xargs xattr -l다시 실행 하고 xattr 속성이있는 파일이 없는지 확인하십시오. 그럼 당신은 갈 수 있습니다 :
tar cjvf file.tar.bz2 dir
참고 URL : https://stackoverflow.com/questions/10924236/mac-zip-compress-without-macosx-folder
'Programing' 카테고리의 다른 글
| Java에서 두 필드를 기준으로 정렬하는 방법은 무엇입니까? (0) | 2020.06.12 |
|---|---|
| 문자열에서 모든 선행 0을 제거하는 방법 (0) | 2020.06.12 |
| Objective-C에서 "인식 할 수없는 선택기가 인스턴스로 전송되었습니다"오류 (0) | 2020.06.12 |
| "다른 사용자가이 기기에 호환되지 않는 버전을 이미 설치했기 때문에이 앱을 설치할 수 없습니다" (0) | 2020.06.12 |
| 값에 관계없이 유형이 항상 특정 크기 인 이유는 무엇입니까? (0) | 2020.06.12 |


