I need to move all files from one folder to another every night

I have several groupfolders that will be filled during the day with files, mostly PDF.
At the end of every day, I need to move the content of those groupfolders to other groupfolders.
How can this be done best?

For example, I have to move the files in groupfolder “from_folder” to “to_folder”.
With occ groupfolders:list I can identify the Folder Id:
Folder ID Groupfolder_Name
4 from_folder
6 to_folder

Then I could create a cron job that does:
mv /wheremyncdatais/__groupfolders/4/* /wheremyncdatais/__groupfolders/6/

However, I do not really know how “safe” that is. Can I do this or should i not go this way? Is there a better way that for sure does not clash with anything?

I was looking at Flows, but there seems no way to trigger a flow based on time, independent of files.

Or, I could simply do this outside NextCloud on a client with i.e. RoboCopy …


Maybe instead of moving files just rename the folder?
If the group folder name is DATA, rename it every night to DATA_DATE
And create a new (empty) folder DATA to be used for uploads next day…

I have not done this…

Hi @anon71540698,
Thanks for the idea.
How would I do that? Looks to me as if i would have to do:
occ groupfolders:rename <folder_id>

rather complex, since groups and permissions are not straightforward for all the groupfolders I need to move the content.
I also have not yet figured out on how to easily get around the <folder_id> which I otherwise have to extract from groupfolders:list.

If I would go further on this road, there might be eventually a way to do that in the DB directly? Not sure, though.

I really hoped the flow app would have a trigger based on time…


Perhaps you can write why you need such a function. If you explain there could be another solutions. If the folder is only used for upload perhaps you can daily create a public share for uploading and use a daily php-redirect (not in nextcloud but a little bit like tinyurls) to the daily public upload folder.


Ok. Normally you must change it daily so you must use your own webserver with php-script.

I can send you a php-program. Ask with private message (PM).
You can wirte a program in php that the destination folder is find with date.

not implemented yet. php must find day and then use the link.


Now you create a lot of nextcloud folders, use public shares (only upload because of security, password possible) and then put them in the days.txt - file . The user must upload with a webspace-link to the script and php finds the correct date and url.

You can share the daily public upload link also in nextcloud with a shared “bookmark”. But you must use the php-script obove or change it daily.


Or you can use the php-script as external site at the top of your nextcloud


Thanks for the idea, @devnull

Basically i have an nc folder “TO_BE_PROCESSED” (actually about 80 different folders at the end of the project) that is filled with files from people from different locations. They use the NextCloud Client on their PC’s.
The folder “TO_BE_PROCESSED” is watched by an application on a windows machine. Unfortunately, I cannot change the behaviour of that application. As soon as it sees a new file in that folder, it grabs it for processing.
So if the people made a mistake and want to change or delete or rename files in the folder “TO_BE_PROCESSED”, they can’t. The file is already gone.
Therefore I would like to introduce an “interim” folder “READY_FOR_PROCESSING” that people use instead.
And only after a couple of hours, typically at the end of the working day, all the files from “READY_FOR_PROCESSING” are moved to “TO_BE_PROCESSED” and then processed by the application.

I think I have found a solution. I can still use my original idea by moving the files with mv(1) and a cronjob. I only have to take care that I do
occ groupfolders:scan
for the source and the destination folders after I moved the data.

Any remarks?