Automatic Moving of Uploaded Files to Another Folder

Hi Nextclouders,

I’ve just deployed my first nextcloud instance using ubuntu and I just have one query.

How do you setup rules that automatically copy/move files automatically from the folder that they have been uploaded to, to another folder?

Please assist.


That has nothing to do with Nextcloud in my opinion.
Take a look at rsync

@machariamaina it doesn’t appear as though that’s possible with core functionality when looking at 11.0.3, though may be covered by an app.

I can certainly see the usecase here, and combined with workflow this would make a lot of sense for sane, automated organisation.

Feel free to create an issue at

Thanks Jason for your response. Hope future releases can take that feature into account.

Thanks for the suggestion, will look into RSync.

I was also searching for this topic. Basically what I need to do is move multiple users automatic photo uploads to a shared photo folder to which they also have access. As far as I can tell you cannot set a specific target folder for camera sync in the mobile client, so a server side workflow of some kind is required.
I see there is a suggestion to use rsync or such on the filesystem itself. How will this affect the NC server/NC DB, no problem as long files are just copied out and not moved I would guess?

There most certainly is :thumbsup:I’ve got a bunch of folders going to a custom location via Android, and it’s possible to change in iOS too.[quote=“OlaP, post:6, topic:12820”]
How will this affect the NC server/NC DB

It isn’t advised if other options exist.

I actually have been doing this for over a year with no problems (I know, at my own risk). Just schedule a cron job to run as often as you need, which runs a bash script that moves files/folders as needed, then don’t forget to run php occ files:scan [all/user account/folder] when the script is done, that part tells Nextcloud to rescan the filesystem which updates its database.
Maybe it’s kind of a hack, but this is my workaround for backing up mobile pictures/videos to my NAS through Nextcloud. Mobile uploads nightly (one way sync with foldersync), sort/move files nightly. Goes right in, then right back out of nextcloud. I’ll manually copy pictures in if I actually want to share them, but I’m sure people don’t care about most of them so there’s no point keeping everything in there.

Sure, if you copy instead of move it’s no problem since you’re not altering what Nextcloud knows about. As long as you don’t care about storing duplicates :wink:

Yeah, you risk (silent) data loss with this method. Less so on single-user, non-shared data but I’d rather avoid risking it and definitely won’t promote it.

External storage was designed for data manipulated outside of NC.

I don’t know where the potential for any data loss would be in this process, so it looks like I need to do more research and come up with a safer solution. I’ll stop recommending this in the forums :innocent:

1 Like

That would be excellent, but I’m not able to find how I can do that on the Nextcloud app for iphone. Are you sure it is possible?

Thank you, this looks like a solution to me - Nextcloud as the frontend feeding another system.
I tested it like this. I created an OneDrive for Business user with access to the shared ODB folder I want to update and provisioned a local ODB folder for this user on a Win server. Anything going into to local Win folder syncs to ODB. (Unfortunatly that goes both ways with ODB so I’m stuck with a local copy as well, but I hear that will change come fall.) Then I setup the local ODB folder as a share and mounted it as CIFS on the Ubuntu Nextcloud is on. A periodic rsync with source delete moving files out of the Nextcloud data folders an into this mount point, followed by a folder scan moves the files all the way to the ODB cloud and clears Nextcloud. (all operations and rights with non-privileged users.) It seems to be working - please point out if you see problems.

@JasonBayton I saw your comment that this might lead to data loss. At what point are you concerned? Since I’m a novice linux user and totally new to Nextcloud, my own primary worry is that it might disrupt the phone’s delta mechanism of what has been transferred already.

Yes, I’ve changed photo backup location on my iPhone. It’s in settings > photos or something. Not super clear. I’ll grab the phone in a minute.[quote=“OlaP, post:13, topic:12820”]
@JasonBayton I saw your comment that this might lead to data loss. At what point are you concerned? Since I’m a novice linux user and totally new to Nextcloud, my own primary worry is that it might disrupt the phone’s delta mechanism of what has been transferred already.

At absolutely any point you access the web interface or use WebDAV with an rsync running in the background. Nextcloud will not hesitate to make changes to data in its root folder which may lead to corruption, removal or otherwise error.

If you’re pulling data from Nextcloud and deleting it it’ll be far safer, but even so I’d still push you to external storage rather than using the inbuilt data folder for this.

In case you continue down this road, as a bandaid until I can get time to change my workflow, I’m putting Nextcloud into maintenance mode before doing any filesystem changes, then taking it back out and doing the rescan to help avoid any sync/delete conflicts.


As Jason stated, rsync files always brings the risk of data corruption, if the files are accessed/changed by Nextcloud, while rsync runs. I don’t know how double access is handled, but I wouldn’t recommend it eather for production systems. But you could lock access for Nextcloud by setting it to maintainance mode with occ command before rsync and turn off maintainance afterwards. Of course you still need to files:scan to bring files into Nextcloud and files:cleanup to delete the moved/removed files from file database. The first can be also limited to the specific upload folder to reduce runtime.

€: Ah someone faster with same solution :slight_smile:

Thanks guys,
For my limited use case, if it is possible to change the target for automatic uploads, that would be all that is needed and a much better option. In that case I can also imagine more complex automation like file renaming and structuring by location, date etc. if you can upload directly to external storage and do file operations there without corrupting anything.

Check out external storage. That’ll set you up nicely.