How to make newly added music file to show up in the Music app?

I have written a tool that downloads m4a files from internet and copies the downloaded m4a file to my Music folder of Nextcloud data. I set the file ownership and group to www-data:www-data.

then it requires me to run

sudo -u www-data /var/www/html/nextcloud/occ files:scan seaurchin -n --path=seaurchiin/files/Entertainment/Music

then in the Music app when I am looking at all tracks or any of selection of left panel. I get below notification at the bottom of the app.

Now after clicking on the above notification runs some command in background and the newly added song starts showing up in the Music app.

My question here is what this command is that run in the background that the newly added song starts showing up in the music app so I straight away run that instea of running files:scan

~# occ music:scan --help
  scan and index any unindexed audio files

  music:scan [options] [--] [<user_id>...]

  user_id                specify one or more targeted users

      --all              target all known users
      --group=GROUP      specify a targeted group to include all users of that group (multiple values allowed)
      --debug            will run the scan in debug mode (memory usage)
      --clean-obsolete   also check availability of any previously scanned tracks, removing obsolete entries
      --rescan           rescan also any previously scanned tracks
      --rescan-modified  rescan files which have mofication time later than the previous scan time (new files not scanned)
      --folder[=FOLDER]  scan only files within this folder (path is relative to the user home folder)
  -h, --help             Display help for the given command. When no command is given display help for the list command
  -q, --quiet            Do not output any message
  -V, --version          Display this application version
      --ansi|--no-ansi   Force (or disable --no-ansi) ANSI output
  -n, --no-interaction   Do not ask any interactive question
      --no-warnings      Skip global warnings, show command output only
  -v|vv|vvv, --verbose   Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

so in your case:

sudo -u www-data /var/www/html/nextcloud/occ music:scan --folder=Entertainment/Music -- seaurchin

would propably do the job.

When you do it manually first with –verbose flag, you will see on the echoes, if you have to change something.

1 Like

btw, this:

is not completely the right way to do it.

first, you name a user seaurchin and then the path, where the user is seaurchiin (with double i)

For the occ files:scan, when a path is given, it reads the user from the path and no user must be attached as argument in the command line.

this is what occ files:scan --help says about it:

 -p, --path=PATH          limit rescan to this path, eg. --path="/alice/files/Music", the user_id is determined by the path and the user_id parameter and --all are ignored

In addition, the options (such as –path= and -n) should be first, folowed ba -- and then the arguments (uid or --all)

So in your case it has to look like this:

sudo -u www-data /var/www/html/nextcloud/occ files:scan -n --path=seaurchiin/files/Entertainment/Music

Does this has to be full path from start to end or just the relative path as you have shown?

This argument of music:scan is relative as shown, i.e. the logic is different than on files:scan.