Skip to main content Skip to navigation

Renaming folders or files

Renaming a folder or file is exactly the same as creating a folder, but uses a HTTP PUT method instead of a POST, and is sent to the URL for the single Atom representation of the folder or file you want to rename. Setting the <title> element overrides the current value, effectively doing a rename.

Just like creating a folder, we send an Atom representation with the <title> set:

<?xml version="1.0" encoding="UTF-8"?>
<entry xmlns="http://www.w3.org/2005/Atom">
  <title>renamed folder</title>
  <content type="text" />
</entry>

Saving this as editfolder.atom, we can send it via cURL to rename the folder:

mat@augustus:~$ curl -i -X PUT --data-binary @editfolder.atom -H 'Content-Type: application/atom+xml' -u cuscav
   "https://files.warwick.ac.uk/files/api/atom/node?account=mmannion&path=mmannion%2FFiles%2FMy+new+folder+name%2F"
Enter host password for user 'cuscav':

HTTP/1.1 200 OK
Date: Tue, 05 Mar 2013 15:50:19 GMT
Content-Type: application/atom+xml;charset=utf-8

<?xml version="1.0" encoding="UTF-8"?>
<entry xmlns="http://www.w3.org/2005/Atom" xmlns:app="http://www.w3.org/2007/app"> xmlns:files="http://go.warwick.ac.uk/elab-schemas/files/atom"
  <title>renamed folder</title>
  <link rel="collection" 
    href="https://files.warwick.ac.uk/files/api/atom/folder?account=mmannion&path=mmannion%2FFiles%2Frenamed+folder%2F" />
  <link rel="edit" 
    href="https://files.warwick.ac.uk/files/api/atom/node?account=mmannion&path=mmannion%2FFiles%2Frenamed+folder%2F" />
  <link rel="alternate" 
    href="https://files.warwick.ac.uk/mmannion/browse/renamed+folder" />
  <id>https://files.warwick.ac.uk/mmannion/browse/renamed+folder</id>
  <updated>2013-03-05T15:50:19.025Z</updated>
  <published>2013-03-05T15:02:24.658Z</published>
  <app:edited>2013-03-05T15:50:19.025Z</app:edited>
  <author>
    <name>Mathew Mannion</name>
  </author>
  <summary type="text">renamed folder/</summary>
  <files:size>25053908</files:size>
  <files:files>10</files:files>
  <files:folders>2</files:folders>
</entry>  

The response is identical to a creation except that there is no Location header and the response is a 200 OK to confirm the operation is complete.

Renaming a file is achieved in exactly the same way:

<?xml version="1.0" encoding="UTF-8"?>
<entry xmlns="http://www.w3.org/2005/Atom">
  <title>mountains.jpg</title>
  <content type="text" />
</entry>

Saving this as editfile.atom, we can send it via cURL to rename the file:

mat@augustus:~$ curl -i -X PUT --data-binary @editfile.atom -H 'Content-Type: application/atom+xml' -u cuscav
   "https://files.warwick.ac.uk/files/api/atom/node?account=mmannion&path=mmannion%2FFiles%2Frenamed+folder%2F01.jpg"
Enter host password for user 'cuscav':

HTTP/1.1 200 OK
Date: Tue, 05 Mar 2013 15:55:48 GMT
Content-Type: application/atom+xml;charset=utf-8

<?xml version="1.0" encoding="UTF-8"?>
<entry xmlns="http://www.w3.org/2005/Atom" xmlns:app="http://www.w3.org/2007/app"> xmlns:files="http://go.warwick.ac.uk/elab-schemas/files/atom"
  <title>mountains.jpg</title>
  <link rel="edit" 
    href="https://files.warwick.ac.uk/files/api/atom/node?account=mmannion&path=mmannion%2FFiles%2Frenamed+folder%2Fmountains.jpg" />
  <link rel="edit-media" 
    href="https://files.warwick.ac.uk/files/api/atom/media?account=mmannion&path=mmannion%2FFiles%2Frenamed+folder%2Fmountains.jpg" />
  <link rel="alternate" 
    href="https://files.warwick.ac.uk/mmannion/files/renamed+folder/mountains.jpg" />
  <id>https://files.warwick.ac.uk/mmannion/files/renamed+folder/mountains.jpg</id>
  <updated>2013-03-05T15:55:48.323Z</updated>
  <published>2013-03-05T15:53:42.112Z</published>
  <app:edited>2013-03-05T15:55:48.323Z</app:edited>
  <author>
    <name>Mathew Mannion</name>
  </author>
  <summary type="text">renamed folder/mountains.jpg</summary>
  <files:mimetype>application/pdf</files:mimetype>
  <files:size>11923854</files:size>
  <files:antivirus>
    <files:checking>false</files:checking>
    <files:checked>true</files:checked>
    <files:hasvirus>false</files:hasvirus>
  </files:antivirus>
</entry>