-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathdvdrenametool.dpr
More file actions
71 lines (68 loc) · 1.65 KB
/
dvdrenametool.dpr
File metadata and controls
71 lines (68 loc) · 1.65 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
program dvdrenametool;
{$IFOPT D-}{$WEAKLINKRTTI ON}{$ENDIF}
{$RTTI EXPLICIT METHODS([]) PROPERTIES([]) FIELDS([])}
{$APPTYPE CONSOLE}
{$R *.res}
uses
System.SysUtils,
System.Classes;
var
// old file (original)
// new file (renamed to original)
FRenameFile: TStringList;
begin
WriteLn('DVDRenameTool 1.0');
try
if ParamCount = 1 then
begin
FRenameFile := TStringList.Create;
try
FRenameFile.LoadFromFile(ParamStr(1), TEncoding.UTF8);
if FRenameFile.Count = 2 then
begin
if FileExists(FRenameFile[0]) and FileExists(FRenameFile[1]) then
begin
// delete original file
if FileExists(FRenameFile[0]) then
begin
DeleteFile(FRenameFile[0]);
end;
if FileExists(FRenameFile[1]) then
begin
if RenameFile(FRenameFile[1], FRenameFile[0]) 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 2 lines');
ExitCode := 3;
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.