A rough bash script for copying an image, changing ownership, and deleting the directory

I wrote this bash script to take an image with a date/time stamp in the file name which has been uploaded from a FOSCAM camera via Linux FTP server, copy and rename the image, change ownership of the image, then delete the directory the FOSCAM creates in the FTP upload folder.


for file in /[directory]/uploads/*/*/*.jpg
cp --no-preserve=all "$file" /var/www/[website]/image.jpg && rm -R /[directory]/uploads/F*

Enhancements are welcome in the comments section.

Inspiration from: https://www.digitalocean.com/community/tutorials/how-to-set-up-vsftpd-for-a-user-s-directory-on-ubuntu-16-04, https://unix.stackexchange.com/questions/115246/file-inheriting-permission-of-directory-it-is-copied-in, https://stackoverflow.com/questions/5130847/running-multiple-commands-in-one-line-in-shell, https://askubuntu.com/questions/832637/automating-a-rename-files-bash-script

Leave a Reply

Your email address will not be published. Required fields are marked *

two × 4 =