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.

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

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 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 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 "" is the input file, and "" 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

ⓘ 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

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.