Edit multiple files at once using change.py

For many years I have used a home grown tool that allows me to make simple changes to multiple files with one command. It is called change and has existed as csh, bash and perl incarnations over the years. I recently rewrote it in python and thought that it might be useful to others so I am publishing it. Here is an example of how it works:

I suspect that lots of you have written your own, similar tools. If that is the case, please look it over send me suggestions for improvements.

You can download it here: http://projects.joelinoff.com/change-1.0/change.py.

Make sure that you call it using the python command or edit the first line to correctly access your local version of python.

Have fun!

Here is the on-line help (-h or –help). It explains things in a bit more detail.

2 thoughts on “Edit multiple files at once using change.py”

  1. Help ! Maybe ?
    I scanned a bunch of pictures into different directories (by year). The file name in each directory came up as “scan001.jpg, scan002.jpg etc. I now realize if I want to move files from 1 directory to another, I will have to rename every one.
    I don’t know what “python” is. I am running on Vista 2006 Home”.
    Do you know a way to change just the first 4 chacters of the file name (to the year) but retain the number portion of the name. (example: scan001 would become 1963001, 0r scan001 in a diferent directory would become 1985001.
    any assist is greatly appreciated !!

    1. > I don’t know what “python” is.

      Python is a scripting language like C#, perl or ruby. It is free and open-source (like perl and ruby) so it won’t cost you anything to download and use.

      The change tool can definitely do what you want. You simply have to run it as follows:

      > cd
      > python change.py –keep-contents ‘scan’ ‘1963’ *.jpg

      Unfortunately, to make it work you have to download and install python on your windows machine.

      If you want to do that navigate to this page: http://www.python.org/download/releases/2.7.2/ and select the Windows MSI (MicroSoft Installer) installer. Once it is installed, you can run change.py from a DOS window as shown above.

      If you do not wish to use python, you may want to look at learning PowerShell programming or look for a windows tool that will do what you want. I am not that familiar with those sorts of tools since I do most everything from the command line.

      Good luck.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.