Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: What I think should be an easy folder monitoring program?  (Read 2695 times)

0 Members and 1 Guest are viewing this topic.

rocketcake

    Topic Starter


    Greenhorn

    What I think should be an easy folder monitoring program?
    « on: June 16, 2009, 09:44:05 PM »
    Hi guys, first post so please go easy.

    I researched around and couldn't find/deduce a definitive answer for this so I am asking for help!

    I'm trying to write a script to monitor a folder for new/modified files, and if execute another batch and then move them to a different folder.

    Basically I'm trying to monitor a folder called /sass, and move the new files/modified from /sass into another folder called /css.


    Here is what I have so far... I put the parts I can't figure out in {} brackets. I tried expressing myself in a form of pseudo-code.


    {monitor folder c:\sass}
       {if newfile||modified file detected}
          // sass is the name of the script im executing, it runs the sass script on the new sass file, then puts the result in the new *.css file
          c:\ruby\bin\sass c:\sass\{newfile||modifiedfile}.sass > c:\css\{newfile||modifiedfile}.css

    I'm not sure:

    1. How to watch the /sass folder for modified/new *.sass files
    2. How to grab the name of the *.sass file into a string, then create a new *.css file using that string. So if I create demo.sass, the batch file will be able to name the output demo.css.

    I hope this is not too confusing. Anyone got some tips for a newbie? ^_^

    rocketcake

      Topic Starter


      Greenhorn

      Re: What I think should be an easy folder monitoring program?
      « Reply #1 on: June 16, 2009, 10:14:11 PM »
      HELP! How do I stop this script? I wrote a script and I can't seem to stop it...

      @echo off
      setlocal
      set srcDir=c:\sass
      set destDir=c:\css
      set lastmod=
      pushd "%srcDir%"
      for /f "tokens=*" %%a in ('dir /b /od 2^>NUL') do set lastmod=%%a
      c:\ruby\bin\sass %srcDir%\%lastmod%.sass > %destDir%\%lastmod%.css

      It seems to always be running in the background. Hmm...

      gh0std0g74



        Apprentice

        Thanked: 37
        Re: What I think should be an easy folder monitoring program?
        « Reply #2 on: June 16, 2009, 10:58:57 PM »
        if you can download and install GNU tools on your system(see my sig)
        1) create a dummy file in the directory you are monitoring eg c:\test\dummyfile.txt
        2) then use this command
        Code: [Select]
        c:\test> find_gnu.exe . -type f -newer dummyfile.txt |xargs -i cp "{}" c:\destination
        c:\test> touch dummyfile.txt

        schedule a job to run this command as needed.

        rocketcake

          Topic Starter


          Greenhorn

          Re: What I think should be an easy folder monitoring program?
          « Reply #3 on: June 17, 2009, 05:40:16 PM »
          thanks ill try this.

          Helpmeh



            Guru

          • Roar.
          • Thanked: 123
            • Yes
            • Yes
          • Computer: Specs
          • Experience: Familiar
          • OS: Windows 8
          Re: What I think should be an easy folder monitoring program?
          « Reply #4 on: June 17, 2009, 06:51:05 PM »
          thanks ill try this.
          If you get any problems, reply and we will help...FEEL FREE TO STICK AROUND!
          Where's MagicSpeed?
          Quote from: 'matt'
          He's playing a game called IRL. Great graphics, *censored* gameplay.