SH to browse folder and copy files [closed]

1

I know it's a little but for someone from windows life gets complicated I need to create a script for linux that runs through a folder where files will be getting from time to time (without specific hours because it will be put by other users), which I do not know what they will be called but I know they will be .wav and I need to copy them to other directory Can you help me? Thank you Greetings

    
asked by Roberto 13.11.2018 в 14:44
source

3 answers

0

I give you the idea that comes to mind:

  • Use cron to schedule the task periodically
  • use find -r <DIRECTORIO> -iregex '.*.wav' to get the list of existing files
  • If you need to copy, you must create a file to know which ones have already been copied and compare to copy only the new ones. Or you can overwrite them if it does not matter.
  • Having the list of files, you can iterate using for and concatenate the file to the gpg command. Example:

for ARCHIVO in $lista do gpg -e -r userID $ARCHIVO ... OTROS COMANDOS ... done

I hope I help you.

    
answered by 13.11.2018 / 16:06
source
0

You could use the linux cp command ...

Create a file with the text editor of your choice and paste the following and modify it by your origin route and the route in which they were saved.

#! /bin/bash

cp -f /tu/ruta/de/origen/*.wav /tu/ruta/de/destino

And you save it as a .sh file and run it from your terminal as ./scriptname.sh or sh_script_name.sh

    
answered by 13.11.2018 в 16:04
-1

It's simple how to use the rsync command:

rsync -avz /origen/ /destino/

this will synchronize the files of both folders in case there is only compare the files that have been modified

you could also do it using the diff command:

diff -qr ./origen ./destino/ | awk '{print $2}' | xargs -n1 -J% cp % ./destino/
    
answered by 13.11.2018 в 16:16