|
@@ -26,6 +26,11 @@ function AutoChangeFileName(AFile: string): string;
|
|
/// 自动替换文件名中的非法字符为
|
|
/// 自动替换文件名中的非法字符为
|
|
/// </summary>
|
|
/// </summary>
|
|
procedure ChangeInvalidFileNameChars(var FileName: string; AChar: Char = '_');
|
|
procedure ChangeInvalidFileNameChars(var FileName: string; AChar: Char = '_');
|
|
|
|
+/// <summary>
|
|
|
|
+/// 清理文件名中的 (1) [1]
|
|
|
|
+/// (1)系统命名,[1]浏览器下载命名,甚至[1] (2)
|
|
|
|
+/// </summary>
|
|
|
|
+function CleanFileName(const Filename: string): string;
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
/// 格式化秒为时间,冒号分割
|
|
/// 格式化秒为时间,冒号分割
|
|
@@ -168,6 +173,33 @@ begin
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+function CleanFileName(const Filename: string): string;
|
|
|
|
+var
|
|
|
|
+ s: string;
|
|
|
|
+ i: integer;
|
|
|
|
+begin
|
|
|
|
+ Result := ExtractFileName(Filename);
|
|
|
|
+ Result := ChangeFileExt(Result, '');
|
|
|
|
+
|
|
|
|
+ // 处理 () 情况
|
|
|
|
+ s := Copy(Result, Length(Result) - 2, 3);
|
|
|
|
+ if (Copy(s, 1, 1) = '(') and (Copy(s, Length(s), 1) = ')') then begin
|
|
|
|
+ i := StrToIntDef(Copy(s, 2, 1), 0);
|
|
|
|
+ if (10 > i) and (i > 0) then
|
|
|
|
+ Result := Copy(Result, 1, Length(Result) - 3);
|
|
|
|
+ end;
|
|
|
|
+
|
|
|
|
+ // 处理 [] 情况
|
|
|
|
+ s := Copy(Result, Length(Result) - 2, 3);
|
|
|
|
+ if (Copy(s, 1, 1) = '[') and (Copy(s, Length(s), 1) = ']') then begin
|
|
|
|
+ i := StrToIntDef(Copy(s, 2, 1), 0);
|
|
|
|
+ if (10 > i) and (i > 0) then
|
|
|
|
+ Result := Copy(Result, 1, Length(Result) - 3);
|
|
|
|
+ end;
|
|
|
|
+
|
|
|
|
+ Result := Trim(Result);
|
|
|
|
+end;
|
|
|
|
+
|
|
function FormatSeconds(const AValue: Double): string; overload;
|
|
function FormatSeconds(const AValue: Double): string; overload;
|
|
var
|
|
var
|
|
h, m, s, ms: Integer;
|
|
h, m, s, ms: Integer;
|