Can I make a workflow for sorting files and how to do it?

I want to make a flow that when I upload a file to a folder “Dropbox” it will tag the file and move it to a folder based on its name and then rename it
for example:
I upload a file to the Dropbox folder
ex: 02[test].txt
it would tag it as English then move it to the school/english folder then rename it to what ever is in the [
The reasion it would move it to english was the 02 on the front of the file
How would I do this

I would recommend to write a batch script to which you parse the file name (%n) and process it as you want. BTW, I wouldn’t recommend to use square brackets in file names because of its special meaning in Linux filters :wink:

See also:

@j-ed How would I write that?

I’ve not tested it but would assume that this could be a way to go:

  1. Create a new “run script” flow which is being executed when a file is uploaded.
  2. Execute a script, e.g. /var/nextcloud/.scripts/ "%n"
  3. Create a script named /var/nextcloud/.scripts/ and fill it with the desired code to be execute, e.g.
  4. Use the “automated tagging” flow to assign a tag
    #  assumption: you upload a file named '02-test.txt' to '/Dropbox' directory
    if [ -n "$fullname" ]
        # parameter not empty
        pname=`dirname "$fullname"`    # get relative path, e.g. '/nate/files/Dropbox'
        dname=`basename "$pname"`      # extract directory name, e.g. "Dropbox"
        fname=`basename "$fullname"`   # get file name, e.g. '02-test.txt'
        if [ "$dname" =" Dropbox" ]
            mv $datadir/$fullname ...
1 Like

Is this what I would put in the Flow UI?

The answer is yes, if …

  • that directory exists on your server
  • the script file exists on your server
  • the web server user is able to access the directory and the script file
  • the script ownership and execution rights have been set correctly.
1 Like

Thank you very much

Moving data folder content around from an external script is nice and all - but how is the system supposed to get notified about this change? By my experience, if I move files around from the shell, NC will show the file in the old place until I do a rescan. Also, if the file has tags, comments etc on it, then those will most definitely not get moved along with it. So, what would be the strategy here?