Skip to content

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

Open

Description

@milianw

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

Activity

  1. blizzz commented on May 18, 2020

    @blizzz
    Member

    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.

  2. milianw commented on May 18, 2020

    @milianw
    Author

    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

  3. milianw commented on May 18, 2020

    @milianw
    Author
  4. XueSheng-GIT commented on Aug 18, 2024

    @XueSheng-GIT

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions