file manipulation

Code for file manipulation

The code snippets on this page are useful for changing attributes of files (e.g. names). This is usually important for pesky software that is very specific about its inputs. Clearly this code can be modified to suit the users purpose.

Bruker OPUS File Extension Trimmer
Language: Python 2.7 (3.4 Compatible)
Author: Leland Gee
This program runs as a script in the target location.

The purpose of this program is to take filenames produced by the OPUS program and remove all 'padding zeroes' from the file extension. For example if my set of files is named 'data.XXXX' the first file being 'data.0001' then 'data.0002' this script will strip them to 'data.1' and 'data.2'. This will work for any amount of zeroes before the final digit but after the file extension dot. This was critical to make the OPUS files useable for another program called 'fit_3d'. It also saves the original files to a backup folder in the same directory.