In this first tutorial you will learn how to quickly convert many files with Atomsk.
▶ For more information, refer to the corresponding documentation page.
When performing simulations, many configuration files may be written. It may be desirable to convert these files for visualization. Of course, Atomsk has built-in capability of doing that, but there is a trick.
If you are used to command-line software, you may want to try this type of command:
atomsk *.xyz cfg
You may assume that this means "Atomsk, convert all my XYZ files into the CFG format".
Well, this is not the case!
This is what will actually happen: before Atomsk is even executed, your shell (for instance, bash) will interpret the wildcard "*.xyz", and replace it with all the file names that match this pattern, so that the command above will actually be expanded into something like that:
atomsk MD0.xyz MD1.xyz MD2.xyz MD3.xyz MD4.xyz MD5.xyz lammps
Now, when it is Atomsk's turn to be executed, what will it do with so many file names? Remember that by default, it accepts only two file names: one as input, and the second one as output. All other file names are ignored. In this example, Atomsk will consider that "MD0.xyz" is the input file, and "MD1.xyz" the output file. Since the latter file exists, Atomsk will prompt to overwrite it. This is of course not what you want to do.
The mode "--list" of Atomsk is designed for this.
First, you have to write the names of all the files you want to convert into a text file, one file name per line. You may do that by hand, or you can use "ls" and redirect its output into a text file:
ls *.xyz > myfiles.lst
ⓘ The text file can have the extension *.txt, *.lst, or any extension you like. What is important is that it is a plain text file.
If you open the file "myfiles.lst" into a text editor, you will see that it contains the file names. Now you can tell Atomsk to convert all these files into the CFG format:
atomsk --list myfiles.lst cfg
Sometimes you convert files dring a simulation, to have a preview. As the simulation goes on, you may want to convert the latest steps, but not convert all the files again.
You may list all the files, but tell Atomsk to ignore the ones that were already converted with the option "-ignore":
ls *.xyz > myfiles.lst
atomsk --list myfiles.lst cfg -ignore
This is a good way to save time when converting files.