The easiest way to pack/zip folder after file changes

I am looking for a way how to create zip file of specific folder in my project after I make some change in source code. I could compare it to SASS file watcher. Every time I change something in tha folder I want this folder to be zipped.

any suggestions?

Comment actions Permalink

Hi there,

Well ... you can do this with custom file watcher. But ...

  • you have to write custom batch/shell script that will do the zipping yourself (e.g use unique timestamps in file name etc).
  • if you modify 2 files at the same time in such folder, the file watcher will be fired twice: once for each modified file (which may not be what you want)

If you are still interested:

  • create custom scope that will include files/folders that you want to watch
  • create new watcher and use that newly created scope there; you may need to set "file type" to "any"
  • the program to execute would be your custom script; you may hardcode paths inside it .. or pass it as a parameter
Comment actions Permalink

hi Andriy,
thing is I don't know how to create such a Watcher. I don't have any experience with Webstorm or IDEA plugin development.
And so far I didn't find any useful guide for my specific case.

My requirements are pretty simple. Files will not changes simultaneously, usually I edit 1 file at the time :)
I don't know where to start. Can you point me to some good resources?


Comment actions Permalink
I don't have any experience with Webstorm or IDEA plugin development.

This has nothing to do with plugin development, at all.

You can see standard file watcher settings for common tasks here:

Based on those you should figure out what needs to be done for custom file.

For example: this is custom file watcher that just copies .js files from one folder to another and renames them a bit (P.S. this is for Windows):

Custom batch script used in that custom file watcher: copy-raw.cmd

copy /Y %1.js /B ..\js\%1.min.js /B
Comment actions Permalink

I created watcher attached in screenshot. But  exception occurred while executing watcher and there is only error "An exception occurred while executing watcher... "

Concept is: 1. There is 'dirs' directory in my project and it has many template subdirectories. something like sub projects.

- dirs
-- subdir1
-- subdir2

I want to to create archive for every subdir in which file has changed.
I still need to implement routine to parse $FilePath and find subdir name in it.

But anyway here is script I have so far


if [ $# -eq 0 ]; then
 echo "Argument is missing"
 exit 1

if [ -e $tpldir/$archiveName ]; then
    echo "Archive $archiveName found. Deleting ..."
    rm $tpldir/$archiveName

# bash check if I am in 'dirs' directory
if [ -d $parentDir ]; then
    if [ -e $tpldir ]; then
        # echo "Template dir exists"
            echo "Packing "$tpldir
            pushd $tpldir
            zip -r -9 -q $archiveName .
            cd ..
            exit 0
        echo "Template $tpldir does not exists"
        exit 2
        echo "You are not in 'dirs' directory"
        exit 3

Screenshot 2014-11-12 22.11.04.png
Comment actions Permalink

I don't know what i am doing wrong here. when I run script from command line './ subdir' it works

Comment actions Permalink

ok, I found stupid erro in Watcher setup. I used $FileName instead $FileName$ ..
Now I need to make this parsing routing, which will be hard I guess. I am not fun of batch scripting :(

Comment actions Permalink

I'm not Linux user so cannot help with bash coding.

My only comment about you having "Immediate file sync" enabled -- this will execute watcher even if you just add a space in file -- it will not wait for file to be saved as it will save it for you after like 1 sec delay or so.

Comment actions Permalink

Is it possible to execute it only after save?

Comment actions Permalink

Yes -- by unchecking that option.

Comment actions Permalink

AAh, of course. Thanks!


Please sign in to leave a comment.