Coder 6 months ago
parent
commit
d7ec10c516

+ 10 - 0
CreateTimePrefixRen/CreateTimePrefixRen.csproj

@@ -0,0 +1,10 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+  <PropertyGroup>
+    <OutputType>Exe</OutputType>
+    <TargetFramework>net8.0</TargetFramework>
+    <ImplicitUsings>enable</ImplicitUsings>
+    <Nullable>enable</Nullable>
+  </PropertyGroup>
+
+</Project>

+ 19 - 0
CreateTimePrefixRen/Program.cs

@@ -0,0 +1,19 @@
+// See https://aka.ms/new-console-template for more information
+Console.WriteLine("Hello, World!");
+Console.WriteLine();
+
+foreach (var arg in args)
+{
+    var fi = new FileInfo(arg);
+    var prefix = fi.CreationTime.ToString("yyMMddHHmm");
+    if(fi.Name.StartsWith(prefix)) continue;
+    var dir = Path.GetDirectoryName(fi.FullName);
+    var name = Path.GetFileName(fi.FullName);
+    var to = Path.Combine(dir,$"{prefix}-{name}");
+    Console.WriteLine($"{prefix} - {name} @ {dir}");
+    fi.MoveTo(to);
+}
+
+Console.WriteLine();
+Console.Write("Done. Press ENTER to exit...");
+Console.ReadLine();

+ 8 - 0
CreateTimePrefixRen/Properties/launchSettings.json

@@ -0,0 +1,8 @@
+{
+  "profiles": {
+    "CreateTimePrefixRen": {
+      "commandName": "Project",
+      "commandLineArgs": "Z:\\1.txt"
+    }
+  }
+}