Computer Hope

Microsoft => Microsoft DOS => Topic started by: rocketcake on June 16, 2009, 09:44:05 PM

Title: What I think should be an easy folder monitoring program?
Post by: rocketcake 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? ^_^
Title: Re: What I think should be an easy folder monitoring program?
Post by: rocketcake 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...
Title: Re: What I think should be an easy folder monitoring program?
Post by: gh0std0g74 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.
Title: Re: What I think should be an easy folder monitoring program?
Post by: rocketcake on June 17, 2009, 05:40:16 PM
thanks ill try this.
Title: Re: What I think should be an easy folder monitoring program?
Post by: Helpmeh 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!