windowsfilebatch-fileautomationfile-monitoring

batch file to start when a new document is saved


okay my question is rather simple I want to create a batch file or a shell script that will start when a file is saved to the documents folder so that it can sort the file to its specified sub folder. can anyone point me in the right direction with this?

I would prefer to not have to install separate programs, and would like to keep this as a batch.

machine note: OS=Windows 7 pro

Thanks in advance!

EDIT: this code works perfect for what I needed:

    @echo off 
    :A
    CD "desktop\file moving test"
    tree

    move /Y 1*.* 1*
    move /Y 2*.* 2*
    move /Y 3*.* 3*
    goto A 

Thank you to every one who answered.


Solution

  • You can either make a batch file, that you use to save the file in the folder, and then run the process you need, or you set it as a windows process, and run a it every n time, to check in differences. If differences are found, then run your logic. Somthing like the following, and compare it to the prior count. I would do it as a scheduled task, that runs your batch file.

    @echo off
    for /f %%A in ('dir ^| find "File(s)"') do set cnt=%%A
    echo File count = %cnt%