Skip to main content

Hello!

 

I have a zap that moves and renames a folder in Dropbox. The structure of the folder names is >project name] project number], so an example would be Zapier 523.553.229 .

 

The zap needs to rename the folder to replace the project number to a different number. No matter what I try, the “Rename File” Dropbox action does rename the folder, but it thinks that the last 4 characters of the folder name are an extension. This means that when I try to rename Zapier 523.553.229 to use its new new 111.222.333 job number for example, the Zap renames the folder to Zapier 111.222.333.229 - meaning that it kept the .229 from the original file name, thinking that its an extension.

 

How do I get it to not think that the last 4 characters (i.e. the “.229” in the example above), and rename the folder correctly (i.e. Zapier 111.222.333)?

 

Thank you all!

Hi @egordin, welcome to the Community! 

Ah, the Rename File is intended to be used for renaming files, not folders so that may be potentially why it’s reading the folder name as a file name with it’s extension at the end. 

There’s an existing feature request for an action to rename Dropbox folders that’s been asked about before in the Community here:

So I’ve gone ahead and added your vote to that since it would be geared to toward renaming folders specifically and shouldn’t run into the same issue of misreading the name as being a file extension. I can’t make any promises around when/if that would definitely be added but we’ll be sure to send you and email as soon as it is!

That all said, I did some digging online and there was an answer in this thread (in Dropbox’s support community) that stated that folders can be renamed using the Dropbox API’s Move endpoint. So I tried using the existing Move File action to see if that would work but it just created a new folder with the new name and put the existing file within that new folder.

But, I did some further testing using Dropbox’s API Request (Beta) action I was able to get it working with the following set up:
feea01c769b5cbbcbbc56c629ad3c9a5.png

You’d just need to change the values for the from_path and to_path parameters in the following code for the Body field to the relevant fields in your Zap that contain the current folder and the new folder name that it needs to be changed to:

{
"allow_ownership_transfer": false,
"allow_shared_folder": false,
"autorename": false,
"from_path": "folder path with existing name goes here",
"to_path": "folder path with new name goes here"
}


Can you give that a try and let me know if that works for you? Happy to help further if you run into any issues! 🙂


Thank you so much for the response! I tried the approach you suggested and I don’t think its working (but I could have messed something up!). Here is the initial set up:

and here is the response:

Amy I doing something wrong?


That’s strange, it looks like you’ve done it correctly @egordin.

Hmm, the error seems to be having an issue with the value for the from_path parameter. Has the folder from step 3 moved or changed at all since that other Dropbox action was last tested? If so, that might be why it’s throwing an error about not being able to find it.

Can you try testing the previous Dropbox action (step 3) again and then test the API Request Dropbox action (step 4) again to see if it then works?


I tried modifying the from_path to be manually entered, I tried renaming a different folder, I tried renaming a file. Always got the same error. Could it be something with my account, the HTPPS method, the Request Headers? I don’t know much about that but nothing I’ve tried seems to work.


Sorry to hear it’s still not working @egordin. I’ve just tried testing again this time by first finding a folder that’s inside another folder (in case it only worked for folders in the root directory), but it was able to successfully rename a folder inside another folder. So the setup of the request you’ve shown previously appears to be correct.

When I then tested the API Request action again it created the same “{"error_summary": "from_lookup/not_found/..", "error": {".tag": "from_lookup", "from_lookup": {".tag": "not_found"}}}” error. I’m pretty sure this was because the folder the action was referencing had just been renamed to Zapier 523.553.333 so it couldn’t find a folder called Zapier 523.553.229. 

Can you test the previous Dropbox action in the Zap (step 3 of your Zap) and share a screenshot showing the full path for the folder that needs to be renamed. And then test the API Request Dropbox action (Step 4) and share a screenshot showing the body of the request that was sent so I can check that the value in the from_path for both are definitely an exact match? Please remove/hide any private information (like names, emails, addresses etc.) from any screenshots before sharing.

One other thing I’d like to check is, are both Dropbox files connecting using the same Dropbox user account? If not, then that might explain why the API Request action isn’t able to find the folder that it needs to rename.

Looking forward to hearing from you!


@SamB I figured out the issue, and it has to do with my Dropbox account being a Dropbox for Business account, rather than an individual account. This is a bit of a long post but hopefully helpful.

 

Your solution would work perfectly for an individual account, and everything you suggested is necessary for a business account too, but some additional steps are needed for those using a Dropbox for Business account.

 

I figured out those steps through a conversation with Dropbox support, who told me the following:

 

It looks like that item may be in your team space.

By default, API calls to the Dropbox API operate in the "member folder" of the connected account, not the "team space". That means that by default, the contents of the team space will not be found.
 
You can configure API calls to operate in the "team space" instead though, in order to interact with files/folders in the team space. To do so, you'll need to set the "Dropbox-API-Path-Root" header. You can find information on how to use this in the Team Files Guide.

 

The above links may be helpful for some people, but they were a bit beyond my technical understanding. After some additional back and forth, he told me this:

To operate in the team space you'll need to set the "Dropbox-API-Path-Root" header. There a few ways that that header can be used, but from the context I have for your use case, it sounds like you would want to use the "root" mode with the namespace ID for your team space. You can get the namespace ID for your team space from the "root_namespace_id" value returned by /2/users/get_current_account.
 
So, from what I can tell for your use case, you would want to set that "Dropbox-API-Path-Root" header value like this:

{".tag": "root", "root": "123456789"}


You should replace 123456789 with your "root_namespace_id" value. Also, note that an account's "root_namespace_id" value can change over time (e.g., due to team changes), but the correct value for an account at any point in time can be retrieved from /2/users/get_current_account.

 

I figured out that the solution (for my situation with the Dropbox for Business account) was to do the following:

 

First: add a new Dropbox API Request (Beta) step before the rename step that queries the https://api.dropboxapi.com/2/users/get_current_account. You need an authorization request header and for that I used the the access token that I got on the Dropbox API page while logged in. I’m not actually sure how to get that access token using Zapier alone. Maybe someone has a suggestion. Either way, this step is to dynamically get the “root_namespace_id” which apparently changes over time ¯\_(ツ)_/¯.

 

 

 

 

Then, to the renaming step that you suggested, I added a “Dropbox-API-Path-Root” to the additional request headers and for the value I followed the suggested format that the Dropbox support person provided. Here’s what that looks like:

 

With that change, it all works! Thank you @SamB for your persistence, and I hope this thread helps anyone else looking to accomplish what I needed to do!


Ah, well that explains it then @egordin! I’m so glad you were able to get to the bottom of it! 😁🎉

Thank you so much for sharing details of how you were able to solve things for your Dropbox Business account. I’m sure this info will definitely be helpful to other folks wanting to rename folders on a business account too. If you need anything else at all just let us know. In the meantime, happy Zapping! ⚡️