File Monitor (moving function from PC to Mac help)

Discussion in 'macOS' started by papo2, Jul 20, 2011.

  1. papo2 macrumors member

    Joined:
    Jun 25, 2010
    #1
    Hello:

    I currently have a Windows box running in my home as a server for FTP, File Sharing, Media Server, etc...

    After purchasing my first MacBook Pro this February (very happy!), I would like to buy a new Mac Mini to migrate all of the functions from the Windows server over to the Mac Mini.

    Before I make the purchase, I would like to ensure I can migrate the functions over and what applications I would need in order to do so.

    So far, I am comfortable with file sharing and FTP on the Mac. However, I have a small notification system I have put together and I would like to ask you Mac experts on how I can replicate a similar setup on Mac OS X.

    Currently, I have an application running as a service (File Notify) that monitors specified folders, for specified behaviors.

    I have another small program (sendemail.exe [command line app]) that I use to send an email notification that is called with a batch file. The batch file passes the name of the file, along with the directory and sends me an email.

    For example, File Notify is currently monitoring a "Download" folder for new file/folder creations. Every time a new file or folder is created under this directory, the app calls a program or batch file to run. (In my case, a batch file.) This batch file then runs a small email application called "sendemail.exe". It passes the filename & directory values and sends me an email using an SMTP account.

    I am sure there is a way to get this same setup running under the Mac OSX, maybe even easier, but I have not idea.
     
  2. r0k macrumors 68040

    r0k

    Joined:
    Mar 3, 2008
    Location:
    Detroit
    #2
    I believe it's a lot easier to do this under OS X but I'm not in front of my Mac to tinker right now and tell you exactly how. I've gotten pretty good with shell scripts on my Linux boxes to detect new files and perform actions when they appear. The same could be done on OS X using bash scripts but I think there is an easier way. Perhaps I will get a chance to take a look at this when I get home. In any regard, don't let the ability to perform actions based on the presence of new files stop you from considering a Mac. It's do-able.
     
  3. papo2 thread starter macrumors member

    Joined:
    Jun 25, 2010
    #3
    Thanks! I appreciate your help. I am trying to migrate over little-by-little.
     
  4. papo2 thread starter macrumors member

    Joined:
    Jun 25, 2010
    #4
    I was able to use Folder Actions and a nice little script that I found to do the job. When I get home, I will post the script just in case someone else wants to use it.

    However, there is one thing that I would like to tweek. The script calls for the email notification to be sent using the Mail.app. When the script is run, Mail.app opens from a minimized or closed state, appearing on my desktop, and sends the email. It is a little annoying that the Mail.app actually appears on the screen as if I wanted to use it.

    I would love for this to be more of a "background task" where it is transparent. (meaning, it does not open mail.app on my screen to send the email)

    Is there something I can add to this script to have the mail.app process the request behind the scenes?:confused:
     
  5. papo2 thread starter macrumors member

    Joined:
    Jun 25, 2010
    #5
    Here is the script that I edited to do what I need it to do. Can anyone help me with the mail.app sending the email while hidden?

    Code:
    property theName : "John Doe"
    property theAddress : "John@Doe.com"
    
    
    on adding folder items to this_folder after receiving added_items
    	set added_Items_List to {}
    	repeat with oneItem in added_items
    		set end of added_Items_List to name of (info for oneItem)
    	end repeat
    	set {TID, text item delimiters} to {text item delimiters, return}
    	set added_Items_List to added_Items_List as text
    	set text item delimiters to TID
    	set dateString to (current date) as string
    	set theBody to "Filename(s):" & return & return & added_Items_List & return & return & dateString (* & name of (info for this_folder) *)
    	tell application "Mail"
    		set newMessage to make new outgoing message with properties {visible:true, subject:"Download Complete", content:theBody}
    		tell newMessage
    			make new to recipient at end of to recipients with properties {name:theName, address:theAddress}
    		end tell
    		
    		send newMessage
    	end tell
    end adding folder items to
     

Share This Page