Linux Mastering Development

Automatically running a script on a file as it is created via SAMBA

I have a Linux machine acting as a local SAMBA file server. Most of the clients are Windows. The server is only accessible from within my intranet, and it only serves photos (jpg, gif, png, etc).

What I want is to rename all files as they are created on the share, so that the filenames reflect the creation time of each file. I am not married to a specific solution. I could write a Python script, or I might use rename as described here. Or something else 🙂

I know I could do this as a post-processing step, but I want to make it more user-proof. Can it be automated?

Addition info:

Each user has a different account and SAMBA password, and are part of the ‘repository’ group. This group has r/w access to the SAMBA share. All files/directories created via SAMBA are user:repository and group:repository. Here is the relevant part of smb.conf:

path = /mnt/repository/photos/
valid users = @repository
force group = repository
inherit owner = yes
create mask = 0660
force create mode = 0660
directory mask = 0770
force directory mode = 0770
writeable = yes
public = no
mangled names = illegal
hosts deny = ALL
hosts allow =

The drive is NTFS. I have it mounted noexec, although I could change this if necessary.

Leave a Reply

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