My FeedDiscussionsHeadless CMS
New
Sign in
Log inSign up
Learn more about Hashnode Headless CMSHashnode Headless CMS
Collaborate seamlessly with Hashnode Headless CMS for Enterprise.
Upgrade ✨Learn more

Is using Chokidar for non-development automation weird?

Rup's photo
Rup
·Jun 20, 2018

I've been meaning to find ways to automate stuff on my desktop, and recently figured I could use chokidar, which is often used for file watching during web development.

I basically just leave a node file running that uses chokidar to watch my desktop and other folders. For one task, anytime I drag an image into a folder, chokidar responds by triggering an applescript (it's actually a JXA script using javascript) that sends an email with that image as an atttachment.

I've also made it watch my desktop so that if I drag an image onto the desktop, or save any other type of file, it moves it to a folder for images/audio/video/text/pdf files, while renaming the file according to a naming convention I've set.

Is this a stupid way of doing this? I know I could use bash to do much of this stuff, but there are some things I simply would never know how to accomplish in bash, whereas by leveraging javascript ttools and node packages I can manipulate the desktop using apple's accesibility features and get creative.