cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Want to know all about tools for creatives that work seamlessly with Dropbox, like Adobe? Well, check it out right here!

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to detect Dropbox folder is renamed. via Dropbox http-api or java-sdk

How to detect Dropbox folder is renamed. via Dropbox http-api or java-sdk

harshap
Helpful | Level 6
After rename folder in Dropbox.

Dropbox 2/files/list_folder/continue api give response that indicate old folder and it's all sub-folder deleted and folder with new name and all old sub-folder with new path created.

For example: 1. Have folder name 'contract test sub category 1' that have sub-folder named 'contract test sub category 1' and sub folder have 'test.png' 2. Rename the folder with 'contract test sub category 0'. Get the response that display below.

Response :
{"entries":
      [{
         ".tag":"deleted",
         "name":"contract test category 0",
         "id":"id:zN8VXp5DPoAAAAAAAAABJw",
         "path_lower":"/contract/contract test category 0",
         "path_display":"/contract/contract test category 0"
       },
       {
         ".tag":"deleted",
         "name":"test.png",
         "path_lower":"/contract/contract test category 1/contract test sub category 1/test.png",
         "path_display":"/contract/contract test category 1/contract test sub category 1/test.png"
       },
       {
         ".tag":"deleted",
         "name":"contract test sub category 1",
         "path_lower":"/contract/contract test category 1/contract test sub category 1",
         "path_display":"/contract/contract test category 1/contract test sub category 1"
       },
       {
         ".tag":"deleted",
         "name":"contract test category 1",
         "path_lower":"/contract/contract test category 1",
         "path_display":"/contract/contract test category 1"
       },
       {
         ".tag":"folder",
         "name":"contract test sub category 1",
         "id":"id:zN8VXp5DPoAAAAAAAAABKg",
         "path_lower":"/contract/contract test category 0/contract test sub category 1",
         "path_display":"/contract/contract test category 0/contract test sub category 1"
       },
       {
         ".tag":"file",
         "name":"test.png",
         "id":"id:zN8VXp5DPoAAAAAAAAABLQ",
         "client_modified":"2019-01-25T12:30:58Z","server_modified":"2019-01-29T06:39:51Z",
         "rev":"0123a000000011c24d890",
         "size":181599,
         "path_lower":"/contract/contract test category 0/contract test sub category 1/test.png",
         "path_display":"/contract/contract test category 0/contract test sub category 1/test.png", 
        }],
     "cursor":"AAGsW7C_w_KUDSqracbrCsltYQBEjFAgIzkiFAc-wW7q_MkvC-bsa2v9PKI9trqUlfwfvhTS-F0aqMQiZyvOMI8RkRVapojCscMh6hda97n4bk1_oC31hz6mAeuvHWaI23w7UnXHWsi9ynVh-__INwtwwOvIdNqIG1cEWZtBtvZrUsRTKgqFkypN7217AtRGOaIeTkeOK01Cc-F50eZbmg9c",
     "has_more":false
   }

I have thousand of sub-folder in folder that i want to rename and run code according to renamed folder.

I want something that indicate 'contract test sub category 1' folder to renamed to 'contract test sub category 0'.

Is there any way to detect particular folder is renamed ? Or any dropbox-api that give my expected results.

2 Accepted Solutions

Accepted Solutions

Re: How to detect Dropbox folder is renamed. via Dropbox http-api or java-sdk

Greg-DB
Dropboxer

[Cross-linking for reference: https://stackoverflow.com/questions/54417566/how-to-detect-dropbox-folder-is-renamed-via-dropbox-htt... ]

If a file or folder is renamed, the new entry will have the same 'id' as the previous (non-deleted) entry.

So, if you want to keep track of renames, you should keep the existing state, from the previous /2/files/list_folder and /2/files/list_folder/continue calls.

Here's a more complete example:

curl -X POST https://api.dropboxapi.com/2/files/create_folder_v2 \
    --header "Authorization: Bearer <ACCESS_TOKEN>" \
    --header "Content-Type: application/json" \
    --data "{\"path\": \"/test/test_325818\"}" | jqp

# {
#   "metadata": {
#     "name": "test_325818",
#     "path_lower": "/test/test_325818",
#     "path_display": "/Test/test_325818",
#     "id": "id:25N5ksooX-sAAAAAAAM5zg"
#   }
# }

curl -X POST https://content.dropboxapi.com/2/files/upload \
    --header "Authorization: Bearer <ACCESS_TOKEN>" \
    --header "Dropbox-API-Arg: {\"path\": \"/test/test_325818/test_325818.txt\"}" \
    --header "Content-Type: application/octet-stream" \
    --data-binary "test data" | jqp

# {
#   "name": "test_325818.txt",
#   "path_lower": "/test/test_325818/test_325818.txt",
#   "path_display": "/test/test_325818/test_325818.txt",
#   "id": "id:25N5ksooX-sAAAAAAAM50A",
#   "client_modified": "2019-01-29T19:08:37Z",
#   "server_modified": "2019-01-29T19:08:37Z",
#   "rev": "73c60021eccc7",
#   "size": 9,
#   "content_hash": "824979ede959fefe53082bc14502f8bf041d53997ffb65cbbe3ade5803f7fb76"
# }

curl -X POST https://api.dropboxapi.com/2/files/list_folder \
    --header "Authorization: Bearer <ACCESS_TOKEN>" \
    --header "Content-Type: application/json" \
    --data "{\"path\": \"/test\",\"recursive\": true}" | jqp

# {
#   "entries": [
#     {
#       ".tag": "folder",
#       "name": "test",
#       "path_lower": "/test",
#       "path_display": "/test",
#       "id": "id:25N5ksooX-sAAAAAAAM5zw"
#     },
#     {
#       ".tag": "folder",
#       "name": "test_325818",
#       "path_lower": "/test/test_325818",
#       "path_display": "/Test/test_325818",
#       "id": "id:25N5ksooX-sAAAAAAAM5zg"
#     },
#     {
#       ".tag": "file",
#       "name": "test_325818.txt",
#       "path_lower": "/test/test_325818/test_325818.txt",
#       "path_display": "/test/test_325818/test_325818.txt",
#       "id": "id:25N5ksooX-sAAAAAAAM50A",
#       "client_modified": "2019-01-29T19:08:37Z",
#       "server_modified": "2019-01-29T19:08:37Z",
#       "rev": "73c60021eccc7",
#       "size": 9,
#       "content_hash": "824979ede959fefe53082bc14502f8bf041d53997ffb65cbbe3ade5803f7fb76"
#     }
#   ],
#   "cursor": "AAEZHC5JNB-5N9UR8wHEdcHTUEbi-u78UPPhZfrt9hPLMhmbDIgPn6pFEmlMk7fItVUgMRA4dpMhLtwuqjlhTYgcDraWbCIpZ0rKJsPui2yTPXNIWIoCCjWzHm_osUCUWMOwGPLDqcXNMvhx5dUAz6fU7QaK0pGJAF08QdpQFV_KJC73PT1MT_DX1TYuDPBWkP4",
#   "has_more": false
# }

curl -X POST https://api.dropboxapi.com/2/files/move_v2 \
    --header "Authorization: Bearer <ACCESS_TOKEN>" \
    --header "Content-Type: application/json" \
    --data "{\"from_path\": \"/test/test_325818\",\"to_path\": \"/test/test_325818_renamed\"}" | jqp

# {
#   "metadata": {
#     ".tag": "folder",
#     "name": "test_325818_renamed",
#     "path_lower": "/test/test_325818_renamed",
#     "path_display": "/Test/test_325818_renamed",
#     "id": "id:25N5ksooX-sAAAAAAAM5zg"
#   }
# }

curl -X POST https://api.dropboxapi.com/2/files/list_folder/continue \
    --header "Authorization: Bearer <ACCESS_TOKEN>" \
    --header "Content-Type: application/json" \
    --data "{\"cursor\": \"AAEZHC5JNB-5N9UR8wHEdcHTUEbi-u78UPPhZfrt9hPLMhmbDIgPn6pFEmlMk7fItVUgMRA4dpMhLtwuqjlhTYgcDraWbCIpZ0rKJsPui2yTPXNIWIoCCjWzHm_osUCUWMOwGPLDqcXNMvhx5dUAz6fU7QaK0pGJAF08QdpQFV_KJC73PT1MT_DX1TYuDPBWkP4\"}" | jqp

# {
#   "entries": [
#     {
#       ".tag": "deleted",
#       "name": "test_325818.txt",
#       "path_lower": "/test/test_325818/test_325818.txt",
#       "path_display": "/test/test_325818/test_325818.txt"
#     },
#     {
#       ".tag": "deleted",
#       "name": "test_325818",
#       "path_lower": "/test/test_325818",
#       "path_display": "/Test/test_325818"
#     },
#     {
#       ".tag": "folder",
#       "name": "test_325818_renamed",
#       "path_lower": "/test/test_325818_renamed",
#       "path_display": "/Test/test_325818_renamed",
#       "id": "id:25N5ksooX-sAAAAAAAM5zg"
#     },
#     {
#       ".tag": "file",
#       "name": "test_325818.txt",
#       "path_lower": "/test/test_325818_renamed/test_325818.txt",
#       "path_display": "/test/test_325818_renamed/test_325818.txt",
#       "id": "id:25N5ksooX-sAAAAAAAM50A",
#       "client_modified": "2019-01-29T19:08:37Z",
#       "server_modified": "2019-01-29T19:09:03Z",
#       "rev": "73c64021eccc7",
#       "size": 9,
#       "content_hash": "824979ede959fefe53082bc14502f8bf041d53997ffb65cbbe3ade5803f7fb76"
#     }
#   ],
#   "cursor": "AAHt9Zlq5FimhWx0HZfGESi174eBTbSFXHS0ZyMQq5PcBgpWjIah3fS6iRKkyqHbmWr5MG-7cX4Bq8p6f6BF0nZ6D6cp26qSXH6kUxaAa_71a3f3hVMT8vDNF3dpxXHp4D57TU2YoEKwGrflmA9jEQbtS4_qZ77eL5Ul-ragoAh9kBLgopvOU7WOWVanQFHbj8I",
#   "has_more": false
# }

In this example, you can see how the folder originally at 
"/test/test_325818" was renamed to "/test/test_325818_renamed", but retained the same 'id' of "id:25N5ksooX-sAAAAAAAM5zg".

View solution in original post

Re: How to detect Dropbox folder is renamed. via Dropbox http-api or java-sdk

harshap
Helpful | Level 6

Thank You Greg.

It really works for me.

View solution in original post

2 Replies 2

Re: How to detect Dropbox folder is renamed. via Dropbox http-api or java-sdk

Greg-DB
Dropboxer

[Cross-linking for reference: https://stackoverflow.com/questions/54417566/how-to-detect-dropbox-folder-is-renamed-via-dropbox-htt... ]

If a file or folder is renamed, the new entry will have the same 'id' as the previous (non-deleted) entry.

So, if you want to keep track of renames, you should keep the existing state, from the previous /2/files/list_folder and /2/files/list_folder/continue calls.

Here's a more complete example:

curl -X POST https://api.dropboxapi.com/2/files/create_folder_v2 \
    --header "Authorization: Bearer <ACCESS_TOKEN>" \
    --header "Content-Type: application/json" \
    --data "{\"path\": \"/test/test_325818\"}" | jqp

# {
#   "metadata": {
#     "name": "test_325818",
#     "path_lower": "/test/test_325818",
#     "path_display": "/Test/test_325818",
#     "id": "id:25N5ksooX-sAAAAAAAM5zg"
#   }
# }

curl -X POST https://content.dropboxapi.com/2/files/upload \
    --header "Authorization: Bearer <ACCESS_TOKEN>" \
    --header "Dropbox-API-Arg: {\"path\": \"/test/test_325818/test_325818.txt\"}" \
    --header "Content-Type: application/octet-stream" \
    --data-binary "test data" | jqp

# {
#   "name": "test_325818.txt",
#   "path_lower": "/test/test_325818/test_325818.txt",
#   "path_display": "/test/test_325818/test_325818.txt",
#   "id": "id:25N5ksooX-sAAAAAAAM50A",
#   "client_modified": "2019-01-29T19:08:37Z",
#   "server_modified": "2019-01-29T19:08:37Z",
#   "rev": "73c60021eccc7",
#   "size": 9,
#   "content_hash": "824979ede959fefe53082bc14502f8bf041d53997ffb65cbbe3ade5803f7fb76"
# }

curl -X POST https://api.dropboxapi.com/2/files/list_folder \
    --header "Authorization: Bearer <ACCESS_TOKEN>" \
    --header "Content-Type: application/json" \
    --data "{\"path\": \"/test\",\"recursive\": true}" | jqp

# {
#   "entries": [
#     {
#       ".tag": "folder",
#       "name": "test",
#       "path_lower": "/test",
#       "path_display": "/test",
#       "id": "id:25N5ksooX-sAAAAAAAM5zw"
#     },
#     {
#       ".tag": "folder",
#       "name": "test_325818",
#       "path_lower": "/test/test_325818",
#       "path_display": "/Test/test_325818",
#       "id": "id:25N5ksooX-sAAAAAAAM5zg"
#     },
#     {
#       ".tag": "file",
#       "name": "test_325818.txt",
#       "path_lower": "/test/test_325818/test_325818.txt",
#       "path_display": "/test/test_325818/test_325818.txt",
#       "id": "id:25N5ksooX-sAAAAAAAM50A",
#       "client_modified": "2019-01-29T19:08:37Z",
#       "server_modified": "2019-01-29T19:08:37Z",
#       "rev": "73c60021eccc7",
#       "size": 9,
#       "content_hash": "824979ede959fefe53082bc14502f8bf041d53997ffb65cbbe3ade5803f7fb76"
#     }
#   ],
#   "cursor": "AAEZHC5JNB-5N9UR8wHEdcHTUEbi-u78UPPhZfrt9hPLMhmbDIgPn6pFEmlMk7fItVUgMRA4dpMhLtwuqjlhTYgcDraWbCIpZ0rKJsPui2yTPXNIWIoCCjWzHm_osUCUWMOwGPLDqcXNMvhx5dUAz6fU7QaK0pGJAF08QdpQFV_KJC73PT1MT_DX1TYuDPBWkP4",
#   "has_more": false
# }

curl -X POST https://api.dropboxapi.com/2/files/move_v2 \
    --header "Authorization: Bearer <ACCESS_TOKEN>" \
    --header "Content-Type: application/json" \
    --data "{\"from_path\": \"/test/test_325818\",\"to_path\": \"/test/test_325818_renamed\"}" | jqp

# {
#   "metadata": {
#     ".tag": "folder",
#     "name": "test_325818_renamed",
#     "path_lower": "/test/test_325818_renamed",
#     "path_display": "/Test/test_325818_renamed",
#     "id": "id:25N5ksooX-sAAAAAAAM5zg"
#   }
# }

curl -X POST https://api.dropboxapi.com/2/files/list_folder/continue \
    --header "Authorization: Bearer <ACCESS_TOKEN>" \
    --header "Content-Type: application/json" \
    --data "{\"cursor\": \"AAEZHC5JNB-5N9UR8wHEdcHTUEbi-u78UPPhZfrt9hPLMhmbDIgPn6pFEmlMk7fItVUgMRA4dpMhLtwuqjlhTYgcDraWbCIpZ0rKJsPui2yTPXNIWIoCCjWzHm_osUCUWMOwGPLDqcXNMvhx5dUAz6fU7QaK0pGJAF08QdpQFV_KJC73PT1MT_DX1TYuDPBWkP4\"}" | jqp

# {
#   "entries": [
#     {
#       ".tag": "deleted",
#       "name": "test_325818.txt",
#       "path_lower": "/test/test_325818/test_325818.txt",
#       "path_display": "/test/test_325818/test_325818.txt"
#     },
#     {
#       ".tag": "deleted",
#       "name": "test_325818",
#       "path_lower": "/test/test_325818",
#       "path_display": "/Test/test_325818"
#     },
#     {
#       ".tag": "folder",
#       "name": "test_325818_renamed",
#       "path_lower": "/test/test_325818_renamed",
#       "path_display": "/Test/test_325818_renamed",
#       "id": "id:25N5ksooX-sAAAAAAAM5zg"
#     },
#     {
#       ".tag": "file",
#       "name": "test_325818.txt",
#       "path_lower": "/test/test_325818_renamed/test_325818.txt",
#       "path_display": "/test/test_325818_renamed/test_325818.txt",
#       "id": "id:25N5ksooX-sAAAAAAAM50A",
#       "client_modified": "2019-01-29T19:08:37Z",
#       "server_modified": "2019-01-29T19:09:03Z",
#       "rev": "73c64021eccc7",
#       "size": 9,
#       "content_hash": "824979ede959fefe53082bc14502f8bf041d53997ffb65cbbe3ade5803f7fb76"
#     }
#   ],
#   "cursor": "AAHt9Zlq5FimhWx0HZfGESi174eBTbSFXHS0ZyMQq5PcBgpWjIah3fS6iRKkyqHbmWr5MG-7cX4Bq8p6f6BF0nZ6D6cp26qSXH6kUxaAa_71a3f3hVMT8vDNF3dpxXHp4D57TU2YoEKwGrflmA9jEQbtS4_qZ77eL5Ul-ragoAh9kBLgopvOU7WOWVanQFHbj8I",
#   "has_more": false
# }

In this example, you can see how the folder originally at 
"/test/test_325818" was renamed to "/test/test_325818_renamed", but retained the same 'id' of "id:25N5ksooX-sAAAAAAAM5zg".

View solution in original post

Re: How to detect Dropbox folder is renamed. via Dropbox http-api or java-sdk

harshap
Helpful | Level 6

Thank You Greg.

It really works for me.

View solution in original post

Poll
Do you work or study in the creative industry? If so, which area?
If you use Adobe, don't forget to check out our latest integrations update here.
Who's talking

Top contributors to this post

  • User avatar
    harshap Helpful | Level 6
  • User avatar
    Greg-DB Dropboxer
What do Dropbox user levels mean?
Need more support?