【问题标题】:Replace SMB address to go to file/folder location on Mac将 smb 地址替换为 \"/Volumes/\"
【发布时间】:2022-08-02 14:14:19
【问题描述】:

我在 MacOS 上,并且经常以 \"smb://196.168.1.13/filepath/filename\" 的格式发送文件路径。我需要将其更改为更友好的 \"/Volumes/filepath/filename\"。

我一直在这里寻找 AppleScript 解决方案,但找不到可以开始工作的解决方案。

我更喜欢剪贴板解决方案,这样我就可以复制路径,运行脚本,然后粘贴修改后的路径。不过,对任何其他方法开放。

完整的菜鸟,所以请温柔。

    标签: macos applescript


    【解决方案1】:

    终于破解了。获取 smb 地址(如果需要,安装卷)并打开文件/文件夹的位置。

    这是特定于我们的服务器的。将地址更改为您的设置。

    on run
        --get the clipboard info
        set Storage to get the clipboard
    
        --Mount the volume if required
        if Storage contains "smb://192.168.1.13/" then
            set findString to "smb://192.168.1.13"
            set theVolume to "/Volumes/"
            set mountedVolumes to every paragraph of (do shell script "mount | awk -F' on ' '{print $2}' | awk -F' \\\\(' '{print $1}'")
            if theVolume is in mountedVolumes then
                --Volume is mounted
            else
                mount volume "smb://192.168.1.13/WIP"
            end if
        end if
        
        --Convert path to mac friendly path
        set replacementString to "/Volumes"
        set newPath to do shell script "sed 's|" & quoted form of findString & "|" & quoted form of replacementString & "|g' <<< " & quoted form of Storage
        
        --Open the file/folder location
        set myFolderLocation to newPath
        tell application "Finder"
            reveal POSIX file myFolderLocation as text
        end tell
    end run
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-05-20
      • 2020-06-10
      • 1970-01-01
      • 1970-01-01
      • 2011-02-05
      • 2013-05-09
      • 2017-03-10
      • 2011-02-16
      相关资源
      最近更新 更多