简体   繁体   English

MacOS终端转到带有空格和括号的文件夹

[英]MacOS Terminal go to a folder with spaces and parenthesis

I'm trying to configure Cyberduck to read the Bookmark files from my Dropbox folder. 我正在尝试配置Cyber​​duck以从我的Dropbox文件夹中读取书签文件。

This is usually accomplished by this command: 这通常通过以下命令完成:

defaults write ch.sudo.cyberduck application.support.path ~/Dropbox/Cyberduck

Super easy!! 超级简单!

But... Dropbox has since changed and if you have a Pro Account the Dropbox folder is renamed "Dropbox (Personal)". 但是...... Dropbox已经改变,如果你有一个专业账户,Dropbox文件夹被重命名为“Dropbox(个人)”。

I've tried to do this: 我试过这样做:

defaults write ch.sudo.cyberduck application.support.path ~/Dropbox\ \(Personal\)/

And I get this error: 我收到这个错误:

not parse: [...]/Dropbox (Personal)/Apps/Cyberduck/.  Try single-quoting it.

I tried single quoting like this but same error: 我试过像这样的单引号但是同样的错误:

defaults write ch.sudo.cyberduck application.support.path '~/Dropbox\ \(Personal\)/'

How can I solve this? 我怎么解决这个问题?

You can single quote escape your parentheses by wrapping them in a double quote: 您可以通过将它们包装在双引号中来单引号转义括号:

Instead of: ln -s '/Users/username/Dropbox (Company Name)/' DropboxCompanyName 而不是: ln -s '/Users/username/Dropbox (Company Name)/' DropboxCompanyName

Do: ln -s "'/Users/username/Dropbox (Company Name)/'" DropboxCompanyName 执行: ln -s "'/Users/username/Dropbox (Company Name)/'" DropboxCompanyName

Notice the double quotes added to /Users/username/Dropbox (Company Name)/ 请注意添加到/Users/username/Dropbox (Company Name)/的双引号

So I cannot find a way to do a "defaults write" to a path with parentheses, but I did this workaround and it seemed to work for me (in my case I needed to link to my enterprise Dropbox account): 所以我找不到一种方法来对带括号的路径进行“默认写入”,但我做了这个解决方法,它似乎对我有用(在我的情况下,我需要链接到我的企业Dropbox帐户):

cd to your home folder and create a symlink of the directory that has the parentheses: cd到您的主文件夹并创建包含括号的目录的符号链接:

ln -s '/Users/username/Dropbox (Company Name)/' DropboxCompanyName

At that point, I was able to do do a defaults write that wrote ~/DropboxCompanyName as part of the path and it worked just fine. 那时,我能够做一个写入〜/ DropboxCompanyName作为路径一部分的默认写入,它工作得很好。

All that said, your personal folder already has a hidden symlink: "Dropbox" that's in the same directory and pointing to "Dropbox (Personal)", so you should be able to do you original command as such: 总而言之,您的个人文件夹已经有一个隐藏的符号链接:“Dropbox”位于同一目录中并指向“Dropbox(个人)”,因此您应该能够执行原始命令:

defaults write ch.sudo.cyberduck application.support.path ~/Dropbox/Cyberduck

… because the "Dropbox" part of the path should still lead to your personal folder. ...因为路径中的“Dropbox”部分仍应导致您的个人文件夹。 This both what I've observed locally (when viewing hidden files) and what Dropbox says on their site: https://www.dropbox.com/help/9031 这就是我在本地观察到的内容(查看隐藏文件时)以及Dropbox在其网站上所说的内容: https//www.dropbox.com/help/9031

I am assuming you are using Unix in Terminal. 我假设你在终端使用Unix。

I have set up a folder of the same name in my Public Folder to test as shown below. 我在公共文件夹中设置了一个同名文件夹进行测试,如下所示。 在此输入图像描述

Your current referencing to the folder would seem correct. 您当前对该文件夹的引用似乎是正确的。 Dragging the folder into the Terminal window current command line will automatically give you the correct referencing to that folder. 将文件夹拖到终端窗口当前命令行将自动为您提供对该文件夹的正确引用。

As an alternative I suggest putting the name of the folder in double quotation marks. 作为替代方案,我建议将文件夹的名称放在双引号中 Even though there are brackets in the name, there is no need to escape these characters in Unix in Terminal in this instance when using double quotation marks. 即使名称中有括号,在使用双引号时,也不需要在终端的Unix中转义这些字符。 This makes it easier to humanly type the correct reference. 这使人们更容易输入正确的参考。

To reference a folder in the image below, for example, the following referencing works for the cd (change directory command): 例如,要引用下图中的文件夹,以下引用适用于cd(更改目录命令):

~/Public/"Dropbox (Personal)" 〜/ Public /“Dropbox(个人)”

Hence I suggest try: 因此我建议尝试:

ch.sudo.cyberduck application.support.path ~/Public/"Dropbox (Personal)"

As for the rest of this command, I am not sure that ch is a valid Unix command. 至于这个命令的其余部分,我不确定ch是否是一个有效的Unix命令。 I do not yet have enough Unix experience to guide you from here. 我还没有足够的Unix经验来指导你从这里开始。

you have to put "" in the whole address 你必须把“”放在整个地址

more like this 更像这样

ch.sudo.cyberduck application.support.path "~/Public/Dropbox (Personal)"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM