nextcloud / workflow_script

Rule based processing of files through specified external scripts
https://apps.nextcloud.com/apps/workflow_script
GNU Affero General Public License v3.0
71 stars 19 forks source link

can a script be used to rename files on upload? #51

Open milianw opened 4 years ago

milianw commented 4 years ago

Steps to reproduce

I've tried to find documentation on this question, but couldn't find anything. So I want to ask here: Is it possible to use a simple script to rewrite (some) file locations as they get uploaded?

I'm using a google pixel phone with auto-uploading enabled. The camera puts portrait pictures into a subfolder, which makes it quite hard to browse through these pictures in any tool other than the google pictures app. The nextcloud gallery also suffers a lot from this. See e.g.: https://support.google.com/pixelphone/thread/12756704?hl=en

So I'm left with workarounds for this android limitation. Currently, I'm running a manual script to rename these files every now and then and then rescan the whole data folder. I'm hoping that a workflow script could improve this situation somehow?

Expected behaviour

Documentation on whether one can move an input file, or whether this will require a rescan then afterwards?

Actual behaviour

I don't want to experiment with this without any documentation. So I don't know if it actually works or not?

Workflow Script app

1.3.1

Server configuration

Operating system: nextcloudpi

Web server: Apache

Database: MySQL

PHP version: 7.3.14

Nextcloud Version: 18.0.4

Where did you install Nextcloud from: nextcloudpi

blizzz commented 4 years ago

Hi Milian :)

Currently, I'm running a manual script to rename these files every now and then and then rescan the whole data folder. I'm hoping that a workflow script could improve this situation somehow?

You can trigger a wrapper script from this workflow to

  1. call you renamer script
  2. rescan the data folder

It will not be detected as move though, so it appears as a new file. So if an affected picture was shared already, the share would get lost, for instance. The data folder scanning can be narrowed to a specific path.

For a proper rename you would fire a WebDAV move request, utilizing curl for instance. It requires you to have an auth token on the machine though. The advantage is that it goes through all Nextcloud business logic.

P.S.: actions of this flow are not instant, but are executed through a background job.

milianw commented 4 years ago

oh that WebDAV hint sounds interesting - thanks! I'll try to look into this eventually and then report back if I managed to get it done using that.

rescanning the data folder is quite expensive so I'd rather not have to do that every time - esp. if I'd upload N such pictures that need to be renamed, I don't want to trigger N rescans. I believe with the WebDAV move I will be able to prevent that. Cool :)

Consider this a feature request though to be able to do a move from within a workflow easily

milianw commented 4 years ago

Btw: I just stalked you - I seem to remember your face. When did we meet? Akademy? Kubuntu? Seems like quite a long time ago :)

XueSheng-GIT commented 1 month ago

Seems there's now also the possibility to use occ files:move to rename files. This could be easier than using webdav.