Atomsk

The Swiss-army knife of atomic simulations

Tutorial: Convert a List of Files

In this first tutorial you will learn how to quickly convert many files with Atomsk.

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.

1. What you should not do

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 wrong.

This is what will actually happen: first, 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, what will Atomsk do with so many file names? 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.

2. The actual way: the mode "--list"

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

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

3. Skip files that were already converted

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.