-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathrenametool.dpr
More file actions
87 lines (83 loc) · 2.1 KB
/
renametool.dpr
File metadata and controls
87 lines (83 loc) · 2.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
program renametool;
{$IFOPT D-}{$WEAKLINKRTTI ON}{$ENDIF}
{$RTTI EXPLICIT METHODS([]) PROPERTIES([]) FIELDS([])}
{$APPTYPE CONSOLE}
{$R *.res}
uses
System.SysUtils,
System.Classes;
var
// audio
// video
// muxed
FRenameFile: TStringList;
begin
WriteLn('RenameTool 1.1');
try
if ParamCount = 1 then
begin
FRenameFile := TStringList.Create;
try
if FileExists(ParamStr(1)) then
begin
FRenameFile.LoadFromFile(ParamStr(1), TEncoding.UTF8);
if FRenameFile.Count = 3 then
begin
if FileExists(FRenameFile[0]) and FileExists(FRenameFile[1]) then
begin
// delete files
if FileExists(FRenameFile[0]) then
begin
DeleteFile(FRenameFile[0]);
Writeln('Deleted ' + FRenameFile[0]);
end;
if FileExists(FRenameFile[1]) then
begin
DeleteFile(FRenameFile[1]);
Writeln('Deleted ' + FRenameFile[1]);
end;
if FileExists(FRenameFile[2]) then
begin
if RenameFile(FRenameFile[2], FRenameFile[1]) then
begin
Writeln('Successfully renamed.');
ExitCode := 0;
end
else
begin
Writeln('Cannot rename');
ExitCode := 5;
end;
end
else
begin
Writeln('Dest doesnt exist.');
ExitCode := 2;
end;
end;
end
else
begin
Writeln('Only 3 lines');
ExitCode := 3;
end;
end
else
begin
Writeln('Unable to find rename text file');
ExitCode := 4;
end;
finally
FRenameFile.Free;
end;
end
else
begin
Writeln('Not enough params: ' + FloatToStr(ParamCount));
ExitCode := 4;
end;
except
on E: Exception do
Writeln(E.ClassName, ': ', E.Message);
end;
end.