need help with moving files automatically using a script.

  • I have a HTPC my parents use without an internet connection. To add new files I go over there with a usb drive and file manager to put them on the htpc. I'd like to set it up so that when the usb drive is plugged in a script will run that will move the contents of the directory on the usb drive to the directory where I keep the media on the htpc. I don't know much about linux but i found this command that may help:

    Quote
    Bash
    #!/bin/bash
    mv /path/to/source /path/to/destination


    For example if the usb folder is /dev/sdb/movies and i want to move the contents to the htpc folder which is /dev/sda/movies the command would look like this.

    Quote


    #!/bin/bash
    mv /dev/sdb/movies /dev/sda/movies


    Is this correct? Does anything need to be changed? What kind of file extension should I give it? I'm creating this on a windows machine.

    Thanks to anyone that helps.

  • The command is correct, as long as the USB device is mounted as /dev/sdb.

    Linux does auto-mount external devices as much as possible, but Kodi has no autostart on inserts of removable devices.
    You can also use the built-in File Manager in Kodi for copying/moving files onto the Kodi box. That option does not require any background or SSH logins to start a script.

  • From what I see bash is used only by sapphire driver package.


    [hr]
    From what I see bash is used only by sapphire driver package.

    Code
    LibreELEC.tv$ fgrep -r bash packages/ | grep DEPENDS
    packages/addons/driver/sapphire/package.mk:PKG_DEPENDS_TARGET="toolchain linux bash"

    Edited once, last by vpeter (December 7, 2016 at 1:06 PM).


  • What kind of file extension should I give it?

    If it is a bash script, there's no need for any extension. If it's a sh script, then I would choose .sh as the extension. You shouldn't use .sh for bash scripts.

    Generally even a sh script will work without an extension of course, as the shebang decides what to use. But AFAIK it's very common to use .sh for sh scripts and no extension for bash scripts.