>> but for some reasons is not working for me
Unable to guess the reasons. Is there ANY output produced when you run this script?
I'm not a batch file expert, but do you REALLY need to use batch file only? If not I highly recommend using something like Cygwin and do the same using a shell script instead.
I also understand that in newer Windows there is something called PowerShell, which is better programmable.