The easiest way to pack/zip folder after file changes
hi,
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?
Please sign in to leave a comment.
Hi there,
Well ... you can do this with custom file watcher. But ...
If you are still interested:
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?
Thanks
This has nothing to do with plugin development, at all.

You can see standard file watcher settings for common tasks here: http://confluence.jetbrains.com/display/PhpStorm/File+Watchers+in+PhpStorm
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
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
--- subdir1.zip
-- subdir2
--- subdir2.zip
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
#!/bin/sh
parentDir="../dirs"
tpldir=$1
archiveName=$tpldir".zip"
if [ $# -eq 0 ]; then
echo "Argument is missing"
exit 1
fi
if [ -e $tpldir/$archiveName ]; then
echo "Archive $archiveName found. Deleting ..."
rm $tpldir/$archiveName
fi
# 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 .
popd
cd ..
exit 0
else
echo "Template $tpldir does not exists"
exit 2
fi
else
echo "You are not in 'dirs' directory"
exit 3
fi
Attachment(s):
Screenshot 2014-11-12 22.11.04.png
I don't know what i am doing wrong here. when I run script from command line './script.sh subdir' it works
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 :(
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.
Is it possible to execute it only after save?
Yes -- by unchecking that option.
AAh, of course. Thanks!