Batch rename/move job best practice?

Hello!

I need to automatically rename all my files according to a specific pattern. Currently it’s a mess, so I would like to write some kind of script that does the job for me.

I used webdav in the past to simply upload files from a website where i want them to be, and that worked very well. However, I am afraid I will need to use the owncloud API now but I can’t really find an example to begin with. Do I really need to write a specific app for what will probably amount to few lines of code, looping through all my files and changing their name/path ?

I assume I cannot simply move them on the filesystem as it would mess up the database. Any help/pointers towards the most proper best practice / documentation page would be appreciated.

Thanks!

Right from the bat I see two more options beside using the API directly:

  1. Run the re-naming/moving script on a machine running ownCloud client instead of on the server itself
  2. Run it on the server and then run an occ files:scan to tell ownCloud about the files: https://doc.owncloud.com/server/10.2/admin_manual/configuration/server/occ_command.html#the-filesscan-command

Downsides of option 1 is the amount of network traffic (isn’t always a downside) and you need the data on the server as well as on a client. Option 2 has the downside that the shares on the old files will be lost.

1 Like

Hi eneubauer,

thank you!

Ah, so if i renamed directly on the server i would simply lose the metadata about the shares and versions? so i assume all content under username/ will still automatically be detected?

If so I think I can live with that, thank you! I will do some testing but seems like the smartest move!

1 Like

There is no automatic detection for fiddling about in the filesystem backend, that’s why you have to run the occ command.

This is always the best idea :wink: I would recommend to set up a quick docker environment on your local workstation, or a clone of your production VM and confirm which behavior is acceptable.

1 Like

Yes, I meant “automatically” when running occ :slight_smile:

thank you again for the quick help! cheers!

1 Like