Saturn72
V2EX  ›  问与答

[求助] 请问大伙 Mac 上怎么批量修改文件打开方式

  •  
  •   Saturn72 · Oct 25, 2024 · 1947 views
    This topic created in 743 days ago, the information mentioned may be changed or developed.

    [求助] 请问大伙 Mac 上怎么批量修改文件打开方式

    用 uni-app 开发微信小程序,不幸安装了 HBuilderX ,导致我打开.json .java .js ... 都自动关联这个****软件,求助有没有办法改过来

    9 replies  •  2024-10-27 21:11:19 +08:00
    donaldturinglee
    donaldturinglee
    Oct 25, 2024
    1
    这个应该和默认 app 有关吧。不过没安装过这个应用,等一位有经验的老哥来解答
    jchnxu
    jchnxu
    Oct 26, 2024
    3
    @WillBeethoven 这是啥软件的截图。感觉很有意思。

    我也是 karabiner 用户 lol
    Saturn72
    Saturn72
    OP
    Oct 26, 2024
    4
    @WillBeethoven 感谢回复,这种应该还是只能针对某一种后缀的来修改? 我在找有没有什么办法可以列出 HBuilderX 到底改了我多少种类文件的默认打开方式
    w3
    w3
    Oct 27, 2024❤️1
    5
    @jchnxu https://shottr.cc/

    @Saturn72
    1. 在 Finder 里找到 HBuilderX ,按 Option + Command + C 复制路径
    2. 替换下面的 /Applications/IntelliJ IDEA.app/Contents/Info.plist 并在 Terminal 里运行
    plutil -convert xml1 -o - '/Applications/IntelliJ IDEA.app/Contents/Info.plist' | xmllint --xpath '//key[.="CFBundleTypeExtensions"]/following-sibling::array/string' - | sed 's/<string>\(.*\)<\/string>/\1/'



    或
    在 info.plist 里直接查找 CFBundleTypeExtensions
    w3
    w3
    Oct 27, 2024
    6
    验证:
    for ext in ipr java groovy kt kts jfr hprof; do
    app=$(duti -x $ext | grep -v '^$')
    echo "Extension: .$ext => Application: $app"
    done




    后续你可以通过 mdls 拿到自己喜欢的编辑器的 bundle identifier 如 com.jetbrains.intellij

    ➜ ~ mdls -name kMDItemCFBundleIdentifier /Applications/IntelliJ\ IDEA.app/
    kMDItemCFBundleIdentifier = "com.jetbrains.intellij"

    然后使用 duti 根据 identifier + file extension 批量修改


    注:我只是提供思路,代码都是让 GPT 写的
    w3
    w3
    Oct 27, 2024❤️1
    7
    @WillBeethoven #6

    批量修改文件默认打开的 app

    for ext in ipr java groovy kt kts jfr hprof; do
    duti -s com.jetbrains.intellij $ext all
    done
    Saturn72
    Saturn72
    OP
    Oct 27, 2024
    9
    @WillBeethoven #7 非常感谢 我来尝试下
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   686 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 36ms · UTC 20:03 · PVG 04:03 · LAX 12:03 · JFK 15:03
    ♥ Do have faith in what you're doing.