Difference between revisions of "ReNamer:Scripts:Move filename portion"
Jump to navigation
Jump to search
(Created page with '{{Up|ReNamer:Scripts}} This script moves a specific portion of a filename to a different position. == Code == Author: Denis Kozlov. Date: 13 February 2007. The starting posit…') |
m (Text replacement - "</source>" to "</syntaxhighlight>") |
||
(One intermediate revision by the same user not shown) | |||
Line 9: | Line 9: | ||
The starting position of the portion, its length and the new position are specifed by constants: '''MOVE_START''', '''MOVE_LENGTH''', '''MOVE_TO'''. | The starting position of the portion, its length and the new position are specifed by constants: '''MOVE_START''', '''MOVE_LENGTH''', '''MOVE_TO'''. | ||
− | < | + | <syntaxhighlight lang="pascal"> |
const | const | ||
MOVE_START = 5; // beginning of the movable portion | MOVE_START = 5; // beginning of the movable portion | ||
Line 26: | Line 26: | ||
end. | end. | ||
− | </ | + | </syntaxhighlight> |
Latest revision as of 15:02, 8 February 2017
This script moves a specific portion of a filename to a different position.
Code
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.
const
MOVE_START = 5; // beginning of the movable portion
MOVE_LENGTH = 3; // length of the movable portion
MOVE_TO = 3; // new position for the portion
var
BaseName, Portion: WideString;
begin
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);
end.