• RE: Script to Combine CIF files

    If your using a MAC (Apple) computer the following code should combine all .cif files in a folder into one file called "total.cif".

    awk '(NR == 1) || (FNR >1)' *.cif>total.cif

    How to use:

    1) Open Terminal

    2) Use the change directory command (i.e. the "cd" command) to find the folder with .cif files for combination.

    3) Once you are in the directory (folder) with the .cif files paste the bold code and hit enter to run the code.

    4) Open the new file called "total.cif" to view all combined .cif files.

     

    Important Notes:

    The "ls" command within terminal will show the contents of the directory (folder). It is a good idea to check that your are in the correct directory before running the code.

     

    The code will generate the "total.cif" file after the code is finished. Do not create a file called "total.cif" otherwise the code will fall into an infinite loop. If you do this use the "control + c" command to stop the code from running indefinitely.

     

    The code can be modified to combine any number of file types by simply changing the "*.cif" to "*.file extenstion" where "file extension" is the type of file you would like to combine. As an example if "*.cif" is changed to "*.csv", all csv files within the directory (folder) will be combined to one file called "total.csv".