Differences between revisions 16 and 17
Revision 16 as of 2009-09-24 17:37:41
Size: 1695
Editor: CarlNobile
Comment:
Revision 17 as of 2009-09-24 17:42:59
Size: 1705
Editor: CarlNobile
Comment:
Deletions are marked like this. Additions are marked like this.
Line 23: Line 23:
 * -o is the original file name using regular expressions if needed.
 * -n is the new file name.
 * -s is the start of the original file set's contiguous sequence numbers.
 * -e is the end of the original file set's contiguous sequence numbers.
 * -r is the new file set's start sequence number.
 * -o is the source file name using regular expressions if needed.
 * -n is the destination file name.
 * -s is the start of the source file set's contiguous sequence numbers.
 * -e is the end of the source
file set's contiguous sequence numbers.
 * -r is the destination file set's start sequence number.

MultiFileRenamer

This is a small script that I wrote in Python some time ago that renames, moves, or copies multiple files. It can use a regular expressions as part of it renaming function.

2009/09/24 -- Added some error messages and converted to new style classes.

rename.py

This is a very flexible script and as such has a lot of command line arguments. If run with no arguments the following usage will be displayed to the screen.

$ rename.py
Usage: /home/cnobile/bin/rename.py -[DNR] -[i Incoming path, d Destination path, o 'File pattern old', n 'File pattern new', s Start sequence, e End sequence, r New sequence start]

The CLI arguments have the following significance.

  • -D is debug mode
  • -N is the NOOP mode
  • -R is the rename mode (Without this argument the files will be copied.)
  • -i is the source path
  • -d is the destination path
  • -o is the source file name using regular expressions if needed.
  • -n is the destination file name.
  • -s is the start of the source file set's contiguous sequence numbers.
  • -e is the end of the source file set's contiguous sequence numbers.
  • -r is the destination file set's start sequence number.

Use a \\n (\n if the entire file name is double quoted) to indicate the sequence number.

Example command line:

$ rename.py -i . -d . -o "p8220\n\n\n.jpg" -n "family-\n\n\n.jpg" -s 1 -e 16 -r 1 -R

If you have 16 JPG files with contiguous sequence numbers from 1 to 16 they will be renamed in the same directory. The above command will rename all the files starting with p8220 to family- plus the sequence number and the .jpg extension.

MultiFileRenamer (last edited 2010-08-07 15:44:54 by CarlNobile)