Code Monkey home page Code Monkey logo

folderwatcher's Introduction

FolderWatcher

A PowerShell (Windows) script that watches folder for new files and archives (moves) them somewhere else.

  • Runs in console without user interaction, with predefined settings.
  • Can be set to start only while specified app is started (and stop when it stops), what makes this script 100% effortless for user โ€“ it starts/runs/stops in background. Instructions are embedded in file โ€“ they involve creating a new task in Scheduler which waits for the app to start/stop.

Why?

Invented primarily for Gnucash but works for any type of files or directory.

Example (Gnucash)

GnuCash creates a lot of backup and log files in the directory of a file that user currently works on. This makes the directory clutter very quickly (depending on GnuCash settings).

Scheduler - New Task

Paste the path to GnuCash.exe into code of both task triggers, e.g.: and *[EventData[Data[@Name='NewProcessName'] and (Data='C:\Program Files (x86)\gnucash\bin\gnucash.exe')]] and and *[EventData[Data[@Name='ProcessName'] and (Data='C:\Program Files (x86)\gnucash\bin\gnucash.exe')]].

Paste your PowerShell custom window title into the code of the task action, e.g.: cmd /c (FOR /F "tokens=1 USEBACKQ" %a IN (`tasklist /fi "imagename eq powershell.exe" /fo table /nh`) DO (if "%a"=="powershell.exe" (taskkill /im powershell.exe /fi "windowtitle eq GnuCash Folder Watcher" & exit) else (start powershell.exe -file "C:\Path\To\FolderWatcher.ps1" & exit)))

script settings

# SETTINGS
$host.ui.RawUI.WindowTitle = "GnuCash Folder Watcher" #appears also in Scheduled Task action above!
$homeDir = 'C:\Path\To\Directory\Budget'
$archiveDir = 'C:\Path\To\Directory\Budget\Archive'
$filter = '*.gnucash.*.*'

Optionally uncomment a line that clears the directory of desired files before Watcher init:

Move-Item "$homeDir\$filter" "$archiveDir".

And enjoy the peace.

folderwatcher's People

Contributors

kaligula0 avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.