This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
If your question is how to create a batch file, the asnwer is that you do it the same way you'd create any other file. You create a FileWriter or FileOutputStream, you write to it, and then you close() it.
If your question is what commands you need to put into that batch file to make it do the things you want, then that has nothing to do with Java, and this site is not an appropriate venue to ask that quesiton.
Why do you want to create the batch file with Java though? Why not just write it by hand?
Janki Dani wrote:Apologies if my question is confusing.
It wasn't the question that was confusing, it was the fact that you posted it twice.
There is a requirement that I want to move some folders from source to destination every 10 days and then create a shortcuts for the moved folder in source drive.
Moving the folders can easily be done with Java, though I probably wouldn't create a Java program just to do that.
Doing it periodically (such as every 10 days) can be done by running your Java app as a service that is always running, and letting it handle its own scheduling, or, more appropriately, by using the Windows Task Scheduler to launch your program on the schedule needed.
Creating the shortcuts is not something that can be done directly with Java, as far as I know, but I could be wrong about that. If they're just a normal file with a particular extension and whose contents indicates the path to the target, then yes, you should be able to do it with Java. If they're a special type of file, then you'd have to use JNI or invoke a Windows command from your Java program.
So, all in all, while it may be possible to do this in Java, I don't think Java is an appropriate tool for this job.
Be aware that "batch file" has a very specific meaning to folks who have been around a while (i.e. old farts, like me). It referred to a file named *.bat and could be run on the DOS/CMD line - much like a Unix shell script.
So when you say "create a batch file using Java", it sounds like you want to use Java to create what is basically a text file with a .bat extension.
What it sounds like you REALLY want is to write a java program that can move/update various files on your system, and then run it at a certain period/date/time.
Is that correct?
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors