Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
milianw opened this issue May 15, 2020 · 4 comments
Open

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

milianw opened this issue May 15, 2020 · 4 comments

Comments

@milianw
Copy link

milianw commented May 15, 2020

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
Copy link
Member

blizzz commented May 18, 2020

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
Copy link
Author

milianw commented May 18, 2020

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

This comment has been minimized.

@XueSheng-GIT
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants