ReNamer:Scripts:Move filename portion

From den4b Wiki
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

This script moves a specific portion of a filename to a different position.


Author: Denis Kozlov. Date: 13 February 2007.

The starting position of the portion, its length and the new position are specifed by constants: MOVE_START, MOVE_LENGTH, MOVE_TO.

  MOVE_START = 5;  // beginning of the movable portion
  MOVE_LENGTH = 3; // length of the movable portion
  MOVE_TO = 3;     // new position for the portion

  BaseName, Portion: WideString;

  BaseName := WideExtractBaseName(FileName);
  Portion := WideCopy(BaseName, MOVE_START, MOVE_LENGTH);
  WideDelete(BaseName, MOVE_START, MOVE_LENGTH);
  WideInsert(Portion, BaseName, MOVE_TO);
  FileName := BaseName + WideExtractFileExt(FileName);