RCDefaultApp 또는 Magic Launch 를 사용하거나 Finder의 정보 패널에서 모두 변경 버튼을 반복해서 누르는 것보다 편리한 것이 있습니까?
Info.plist 파일에서 CFBundleDocumentTypes 배열을 수정하는 쉘 스크립트 작성에 대해 생각했습니다. 그러나 각 앱에는 변경해야 할 여러 키 (때로는 아이콘)가 있습니다.
lsregister
Launch Services 데이터베이스를 구체적으로 수정하는 데 사용할 수 없습니다.
$ `locate lsregister` -h
lsregister: [OPTIONS] [ <path>... ]
[ -apps <domain>[,domain]... ]
[ -libs <domain>[,domain]... ]
[ -all <domain>[,domain]... ]
Paths are searched for applications to register with the Launch Service database.
Valid domains are "system", "local", "network" and "user". Domains can also
be specified using only the first letter.
-kill Reset the Launch Services database before doing anything else
-seed If database isn't seeded, scan default locations for applications and libraries to register
-lint Print information about plist errors while registering bundles
-convert Register apps found in older LS database files
-lazy n Sleep for n seconds before registering/scanning
-r Recursive directory scan, do not recurse into packages or invisible directories
-R Recursive directory scan, descending into packages and invisible directories
-f force-update registration even if mod date is unchanged
-u unregister instead of register
-v Display progress information
-dump Display full database contents after registration
-h Display this help
답변
듀티
- pkg 설치 프로그램을 다운로드하거나 소스에서 컴파일
-
다음과 같은 파일을 어딘가에 저장하십시오.
com.macromates.textmate public.shell-script all com.macromates.textmate public.unix-executable all com.macromates.textmate com.apple.property-list all org.videolan.vlc .avi all org.videolan.vlc .mkv all # ...
-
duti $file.duti
번들 식별자 또는 UTI 찾기 :
bundleid() {
osascript -e "id of app \"$*\""
}
getuti() {
local f="/tmp/me.lri.getuti.${1##*.}"
touch "$f"
mdimport "$f"
mdls -name kMDItemContentTypeTree "$f"
rm "$f"
}
lsapps
내가 알기 전에 duti와 비슷한 루비 스크립트를 작성했습니다. 변경 사항을 적용하려면 OS를 다시 시작해야합니다. 또한에 대한 외부 변경 사항을 덮어 씁니다 com.apple.LaunchServices.plist
.
#!/usr/bin/env ruby
datafile = "#{ENV['HOME']}/Notes/lsapps.txt"
cachedir = "#{ENV['HOME']}/Library/Caches/me.lri.scripts"
cachefile = cachedir + "/lsapps"
`mkdir -p #{cachedir}; touch #{cachefile}`
cachetext = IO.read(cachefile)
a = []
IO.readlines(datafile).each do |line|
line.strip!
next unless line =~ /^([^#].*): (.+)/
z = $1, $2
bid = cachetext.scan(/#{z[0]} (.*)/)[0]
unless bid
bid = `osascript -e 'id of app "#{z[0]}"'`.chomp
next unless bid
File.open(cachefile, "a") { |f| f.puts(z[0] + " " + bid) }
end
z[1].strip.split(" ").each do |e|
if e =~ /(.+):\/\/$/
a << "{LSHandlerURLScheme='#{$1}';LSHandlerRoleAll='#{bid}';}"
elsif e.include?(".")
a << "{LSHandlerContentType='#{e}';LSHandlerRoleAll='#{bid}';}"
else
a << "{LSHandlerContentTag='#{e}';LSHandlerContentTagClass=\
'public.filename-extension';LSHandlerRoleAll='#{bid}';}"
end
end
end
system("defaults", "write", "com.apple.LaunchServices", "LSHandlers",
"(" + a.join(",") + ")")
`defaults write com.apple.LaunchServices LSQuarantine -bool false`
lsapps.txt
NetNewsWire Lite: feed:// public.rss
iCal: icaltodo icalevent
Google Chrome: chrome://
Safari: public.html
TextEdit: txt text md markdown csv
TextMate: public.shell-script public.unix-executable public.script ssh:// xml plist dict css rst tex sh pl py rb gemspec php js java c h m conf bash opml as cfm cfml class coffee ctp erb rhtml haml less msass scss yaml rd
VLC: avi mpg flv mkv mp4 flac 3gp
The Unarchiver: rar
Skim: pdf
iChm: chm
AppleScript Editor: scpt
Sequential: png jpg
답변
스크립팅없이 모든 AVI를 여는 응용 프로그램을 쉽게 변경할 수 있습니다. AVI 파일을 찾아서 정보를 얻습니다. 파일 정보가 표시됩니다. 파일을 열 프로그램을 선택한 다음 “모두 변경 …”버튼을 클릭하십시오. 기본 연결을 변경하라는 메시지가 표시됩니다.
작은 지점과 마찬가지로 리소스 포크는 단계적으로 중단되지 않지만 제작자 코드는 단계적으로 종료됩니다. 따라서 최신 Mac OS 시스템에는 파일을 여는 방법에 대한보다 유연한 시스템이 있습니다. 응용 프로그램은 리소스 포크가없는 파일에서 작동하지만 일부 응용 프로그램에서는 여전히 사용합니다.