cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Back again with another edition of 'How we use Dropbox', so find out how Emma uses to-do lists to get it all done 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: 

Renaming a file/folder using swifty dropbox

Renaming a file/folder using swifty dropbox

Mark L.45
Collaborator | Level 8

Hi,

 

Sorry, a stupid question. I want to rename a file within my dropbox using the swifty dropbox API. But I don't find a rename method and I wanted to check with you the procedure I should be using? 

 

Thanks

Mark

1 Accepted Solution

Accepted Solutions

Re: Renaming a file/folder using swifty dropbox

Greg-DB
Dropboxer

Hi Mark, you can use the move method to rename files or folders.

View solution in original post

2 Replies 2

Re: Renaming a file/folder using swifty dropbox

Greg-DB
Dropboxer

Hi Mark, you can use the move method to rename files or folders.

View solution in original post

Re: Renaming a file/folder using swifty dropbox

Mark L.45
Collaborator | Level 8

Thanks Greg,

 

Here the bear bones code for your readers I put togther; it swaps two files.

 

let randx = Int(arc4random_uniform(32768))
let sourcePathC = sourcePathB + String(randx)
let client = DropboxClientsManager.authorizedClient!
_ = client.files.move(fromPath: sourcePathA, toPath: sourcePathC, allowSharedFolder: false, autorename: true)
  .response { response, error in
  self.theApp.isNetworkActivityIndicatorVisible = true
  if let response = response {
    _ = client.files.move(fromPath: sourcePathB, toPath: sourcePathA, allowSharedFolder: false, autorename: true)
    .response { response, error in
    if let response = response {
      _ = client.files.move(fromPath: sourcePathC, toPath: sourcePathB, allowSharedFolder: false, autorename: true)
      .response { response, error in
      if let response = response {
        self.theApp.isNetworkActivityIndicatorVisible = false
      }
    }
  }
}
}
}

Poll
We love to learn from the educators who use Dropbox. Whether you teach kids, teens, adults or a combination of all three, we want to know what apps and integrations you use with Dropbox to help with teaching. Which of the ones below is your favorite, or most used tool?
Who's talking

Top contributors to this post

  • User avatar
    Mark L.45 Collaborator | Level 8
  • User avatar
    Greg-DB Dropboxer
What do Dropbox user levels mean?
Need more support?