8

How to edit file or folder name using dropbox api?

I was using this reference: https://www.dropbox.com/developers/core/docs

Is there anything else?
Is it even possible?

user990635
  • 3,979
  • 13
  • 45
  • 66

2 Answers2

9

Your question title and body seem to ask slightly different questions, so I'll answer both:

You can edit a file (i.e., its contents) by uploading a new version of it, e.g., using the /files_put call:

https://www.dropbox.com/developers/core/docs#files_put

You can rename a file or folder using the /filesops/move endpoint:

https://www.dropbox.com/developers/core/docs#fileops-move

Greg
  • 16,359
  • 2
  • 34
  • 44
  • tnx lol :) I meant the second :) so I should make from_path and to_path the same, and the to_path will include the new name? is this correct? – user990635 Jul 22 '13 at 19:01
  • 1
    if you just want to rename a file or folder inside a given folder, yes, from_path and to_path should retain the parent folder, and you would just change to_path to have the desired filename. for example, from_path="/my_folder/file.txt" and to_path="/my_folder/new_name.txt" – Greg Jul 22 '13 at 19:39
  • Thanks a lot to both of you. It saves my time and efforts. My link is look like : 'api.dropboxapi.com/1/fileops/move?root=auto&from_path=test.xlsx&to_path=renamed-test.xlsx' Thanks for last two comments as well +1 for both. – Jimmy Mar 16 '16 at 19:03
0

Don't worry about this, if you have a file and you want to rename it, then simply follow this logic it will solve your problem.

  1. Get Name of File and Change it and store the change name in string variable.
  2. Keep Parent Path of the original File.
  3. Move File to other place with the change Name get from String variable.
  4. Now move the File back from new place to old place,
                 How to do it Programatically,
  Entry global_file;//assign any file to it 
  String FilePath=global_file.path;
  String parent_path=global_file.parentPath();//Keep parent path 

    String ChanageName= "Your changed Name";
    parent_path=parent_path+""+ChanageName; //setting path for renamed file to move to its original place.


    Entry RenamedFile    = mApi.move(FilePath, "/"+ChanageName);  //move to new place "/"
    Entry MoveRenameFile = mApi.move(RenamedFile.path,parent_path); //move to previous location
Pir Fahim Shah
  • 10,505
  • 1
  • 82
  • 81