diff --git a/WechatMediaRenamer.sln b/WechatMediaRenamer.sln
new file mode 100644
index 0000000..36d7aaf
--- /dev/null
+++ b/WechatMediaRenamer.sln
@@ -0,0 +1,25 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Blend for Visual Studio Version 16
+VisualStudioVersion = 16.0.30717.126
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WechatMediaRenamer", "WechatMediaRenamer\WechatMediaRenamer.csproj", "{4CDBBF26-46DA-4A3C-B5A8-F4E895463F99}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {4CDBBF26-46DA-4A3C-B5A8-F4E895463F99}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {4CDBBF26-46DA-4A3C-B5A8-F4E895463F99}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {4CDBBF26-46DA-4A3C-B5A8-F4E895463F99}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {4CDBBF26-46DA-4A3C-B5A8-F4E895463F99}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {D30908F1-B7E2-40A3-B59A-D8ADD122DBA9}
+ EndGlobalSection
+EndGlobal
diff --git a/WechatMediaRenamer/App.config b/WechatMediaRenamer/App.config
new file mode 100644
index 0000000..56efbc7
--- /dev/null
+++ b/WechatMediaRenamer/App.config
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/WechatMediaRenamer/App.xaml b/WechatMediaRenamer/App.xaml
new file mode 100644
index 0000000..a237902
--- /dev/null
+++ b/WechatMediaRenamer/App.xaml
@@ -0,0 +1,9 @@
+
+
+
+
+
diff --git a/WechatMediaRenamer/App.xaml.cs b/WechatMediaRenamer/App.xaml.cs
new file mode 100644
index 0000000..8551e37
--- /dev/null
+++ b/WechatMediaRenamer/App.xaml.cs
@@ -0,0 +1,17 @@
+using System;
+using System.Collections.Generic;
+using System.Configuration;
+using System.Data;
+using System.Linq;
+using System.Threading.Tasks;
+using System.Windows;
+
+namespace WechatMediaRenamer
+{
+ ///
+ /// App.xaml 的交互逻辑
+ ///
+ public partial class App : Application
+ {
+ }
+}
diff --git a/WechatMediaRenamer/MainWindow.xaml b/WechatMediaRenamer/MainWindow.xaml
new file mode 100644
index 0000000..e1ac3e3
--- /dev/null
+++ b/WechatMediaRenamer/MainWindow.xaml
@@ -0,0 +1,22 @@
+
+
+
+
+
+
+
+
+
+
+
diff --git a/WechatMediaRenamer/MainWindow.xaml.cs b/WechatMediaRenamer/MainWindow.xaml.cs
new file mode 100644
index 0000000..5531a4e
--- /dev/null
+++ b/WechatMediaRenamer/MainWindow.xaml.cs
@@ -0,0 +1,67 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.IO;
+using System.Text.RegularExpressions;
+
+namespace WechatMediaRenamer
+{
+ ///
+ /// MainWindow.xaml 的交互逻辑
+ ///
+ public partial class MainWindow : Window
+ {
+
+ private static readonly DateTime epoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
+ private static readonly TimeSpan chinaTimeSpan = new TimeSpan(8, 0, 0);
+ private static readonly TimeZoneInfo chinaTime = TimeZoneInfo.CreateCustomTimeZone("CST", chinaTimeSpan, "China Standard SR Time", "SR Time");
+
+ public MainWindow()
+ {
+ InitializeComponent();
+ }
+
+ private void Button_Click(object sender, RoutedEventArgs e)
+ {
+ Environment.Exit(0);
+ }
+
+ private void Ellipse_Drop(object sender, DragEventArgs e)
+ {
+ if (e.Data.GetDataPresent(DataFormats.FileDrop))
+ {
+ string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
+ RenameFiles(files);
+ }
+ }
+
+ private void RenameFiles(string[] files)
+ {
+ MediaFileRenamer mediaFileRenamer;
+ StringBuilder sb = new StringBuilder();
+ foreach (var filePath in files)
+ {
+ mediaFileRenamer = MediaFileRenamer.FromFilePath(filePath);
+ string renameMessage = mediaFileRenamer.Rename();
+ if (renameMessage.Length > 0)
+ {
+ sb.AppendLine(renameMessage);
+ }
+ }
+ if (sb.Length > 0)
+ {
+ MessageBox.Show(sb.ToString());
+ }
+ }
+ }
+}
diff --git a/WechatMediaRenamer/MediaFileRenamer.cs b/WechatMediaRenamer/MediaFileRenamer.cs
new file mode 100644
index 0000000..e1b4faa
--- /dev/null
+++ b/WechatMediaRenamer/MediaFileRenamer.cs
@@ -0,0 +1,89 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.IO;
+using System.Text.RegularExpressions;
+
+namespace WechatMediaRenamer
+{
+ class MediaFileRenamer
+ {
+ public string FullFilePath { get; }
+ public string FullDirectoryPath { get; }
+ public string FileNameWithoutExtension { get; }
+ public string Extension { get; }
+
+ private static readonly DateTime epoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
+ private static readonly TimeSpan chinaTimeSpan = new TimeSpan(8, 0, 0);
+ private static readonly TimeZoneInfo chinaTime = TimeZoneInfo.CreateCustomTimeZone("CST", chinaTimeSpan, "China Standard SR Time", "SR Time");
+
+ public static MediaFileRenamer FromFilePath(string filePath)
+ {
+ return new MediaFileRenamer(filePath);
+ }
+
+ public MediaFileRenamer(string filePath)
+ {
+ this.FullFilePath = filePath;
+ this.FullDirectoryPath = Path.GetDirectoryName(filePath);
+ this.FileNameWithoutExtension = Path.GetFileNameWithoutExtension(filePath);
+ this.Extension = Path.GetExtension(filePath);
+ }
+
+ public string Rename()
+ {
+ string epochTime = GetDatePart(this.FileNameWithoutExtension);
+ if (epochTime.Equals(String.Empty) || epochTime.Length != 13)
+ {
+ return String.Format("无法识别文件 '{0}'中的Epoch时间!", this.FullFilePath);
+ }
+ string destPath = Path.Combine(this.FullDirectoryPath, ComposeNameFromEpochTime(epochTime));
+ if (File.Exists(destPath))
+ {
+ return String.Format("'{0}' 无法被重命名为 '{1}',因为目标已存在!", this.FullFilePath, destPath);
+ }
+ File.Move(this.FullFilePath, destPath);
+ return String.Empty;
+ }
+
+ private string GetDatePart(string fileNameWithoutExtention)
+ {
+ string datePattern = @"[^\d]*(\d+)";
+ Match m = Regex.Match(fileNameWithoutExtention, datePattern, RegexOptions.IgnoreCase);
+ if (m.Success && m.Groups.Count > 1)
+ return m.Groups[1].Value;
+ return String.Empty;
+ }
+
+ private string GetFileNameTemplateByExtention(string extName)
+ {
+ switch (extName.ToLower())
+ {
+ case ".mp4":
+ return "VID_{0}{1}";
+ case ".jpg":
+ case ".jpeg":
+ case ".png":
+ case ".gif":
+ return "IMG_{0}{1}";
+ default:
+ return "{0}{1}";
+ }
+ }
+
+ private string ComposeNameFromEpochTime(string epochTime)
+ {
+ string dateTimePart = String.Format("{0:yyyyMMdd_HHmmss}", GetDateTimeInChinaFromEpochTime(epochTime));
+ string fileNameTemplate = GetFileNameTemplateByExtention(this.Extension);
+ return String.Format(fileNameTemplate, dateTimePart, this.Extension);
+ }
+
+ private DateTime GetDateTimeInChinaFromEpochTime(string epochTime)
+ {
+ DateTime utcDateTime = epoch.AddMilliseconds(long.Parse(epochTime));
+ return TimeZoneInfo.ConvertTimeFromUtc(utcDateTime, chinaTime);
+ }
+ }
+}
diff --git a/WechatMediaRenamer/Properties/AssemblyInfo.cs b/WechatMediaRenamer/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..d6be4f9
--- /dev/null
+++ b/WechatMediaRenamer/Properties/AssemblyInfo.cs
@@ -0,0 +1,55 @@
+using System.Reflection;
+using System.Resources;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+using System.Windows;
+
+// 有关程序集的一般信息由以下
+// 控制。更改这些特性值可修改
+// 与程序集关联的信息。
+[assembly: AssemblyTitle("WpfApp1")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("WpfApp1")]
+[assembly: AssemblyCopyright("Copyright © 2020")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// 将 ComVisible 设置为 false 会使此程序集中的类型
+//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
+//请将此类型的 ComVisible 特性设置为 true。
+[assembly: ComVisible(false)]
+
+//若要开始生成可本地化的应用程序,请设置
+//.csproj 文件中的 CultureYouAreCodingWith
+//例如,如果您在源文件中使用的是美国英语,
+//使用的是美国英语,请将 设置为 en-US。 然后取消
+//对以下 NeutralResourceLanguage 特性的注释。 更新
+//以下行中的“en-US”以匹配项目文件中的 UICulture 设置。
+
+//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
+
+
+[assembly: ThemeInfo(
+ ResourceDictionaryLocation.None, //主题特定资源词典所处位置
+ //(未在页面中找到资源时使用,
+ //或应用程序资源字典中找到时使用)
+ ResourceDictionaryLocation.SourceAssembly //常规资源词典所处位置
+ //(未在页面中找到资源时使用,
+ //、应用程序或任何主题专用资源字典中找到时使用)
+)]
+
+
+// 程序集的版本信息由下列四个值组成:
+//
+// 主版本
+// 次版本
+// 生成号
+// 修订号
+//
+//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
+//通过使用 "*",如下所示:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/WechatMediaRenamer/Properties/Resources.Designer.cs b/WechatMediaRenamer/Properties/Resources.Designer.cs
new file mode 100644
index 0000000..dff52c9
--- /dev/null
+++ b/WechatMediaRenamer/Properties/Resources.Designer.cs
@@ -0,0 +1,70 @@
+//------------------------------------------------------------------------------
+//
+// 此代码由工具生成。
+// 运行时版本: 4.0.30319.42000
+//
+// 对此文件的更改可能导致不正确的行为,如果
+// 重新生成代码,则所做更改将丢失。
+//
+//------------------------------------------------------------------------------
+
+
+namespace WechatMediaRenamer.Properties
+{
+ ///
+ /// 强类型资源类,用于查找本地化字符串等。
+ ///
+ // 此类是由 StronglyTypedResourceBuilder
+ // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
+ // 若要添加或删除成员,请编辑 .ResX 文件,然后重新运行 ResGen
+ // (以 /str 作为命令选项),或重新生成 VS 项目。
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ internal class Resources
+ {
+
+ private static global::System.Resources.ResourceManager resourceMan;
+
+ private static global::System.Globalization.CultureInfo resourceCulture;
+
+ [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
+ internal Resources()
+ {
+ }
+
+ ///
+ /// 返回此类使用的缓存 ResourceManager 实例。
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Resources.ResourceManager ResourceManager
+ {
+ get
+ {
+ if ((resourceMan == null))
+ {
+ global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("WpfApp1.Properties.Resources", typeof(Resources).Assembly);
+ resourceMan = temp;
+ }
+ return resourceMan;
+ }
+ }
+
+ ///
+ /// 重写当前线程的 CurrentUICulture 属性,对
+ /// 使用此强类型资源类的所有资源查找执行重写。
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Globalization.CultureInfo Culture
+ {
+ get
+ {
+ return resourceCulture;
+ }
+ set
+ {
+ resourceCulture = value;
+ }
+ }
+ }
+}
diff --git a/WechatMediaRenamer/Properties/Resources.resx b/WechatMediaRenamer/Properties/Resources.resx
new file mode 100644
index 0000000..af7dbeb
--- /dev/null
+++ b/WechatMediaRenamer/Properties/Resources.resx
@@ -0,0 +1,117 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/WechatMediaRenamer/Properties/Settings.Designer.cs b/WechatMediaRenamer/Properties/Settings.Designer.cs
new file mode 100644
index 0000000..082fc95
--- /dev/null
+++ b/WechatMediaRenamer/Properties/Settings.Designer.cs
@@ -0,0 +1,29 @@
+//------------------------------------------------------------------------------
+//
+// This code was generated by a tool.
+// Runtime Version:4.0.30319.42000
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+//------------------------------------------------------------------------------
+
+
+namespace WechatMediaRenamer.Properties
+{
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
+ internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
+ {
+
+ private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
+
+ public static Settings Default
+ {
+ get
+ {
+ return defaultInstance;
+ }
+ }
+ }
+}
diff --git a/WechatMediaRenamer/Properties/Settings.settings b/WechatMediaRenamer/Properties/Settings.settings
new file mode 100644
index 0000000..033d7a5
--- /dev/null
+++ b/WechatMediaRenamer/Properties/Settings.settings
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/WechatMediaRenamer/WechatMediaRenamer.csproj b/WechatMediaRenamer/WechatMediaRenamer.csproj
new file mode 100644
index 0000000..34bd56a
--- /dev/null
+++ b/WechatMediaRenamer/WechatMediaRenamer.csproj
@@ -0,0 +1,108 @@
+
+
+
+
+ Debug
+ AnyCPU
+ {4CDBBF26-46DA-4A3C-B5A8-F4E895463F99}
+ WinExe
+ WpfApp1
+ WpfApp1
+ v4.7.2
+ 512
+ {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
+ 4
+ true
+ true
+
+
+ AnyCPU
+ true
+ full
+ false
+ bin\Debug\
+ DEBUG;TRACE
+ prompt
+ 4
+
+
+ AnyCPU
+ pdbonly
+ true
+ bin\Release\
+ TRACE
+ prompt
+ 0
+
+
+ hnet.com-image.ico
+
+
+
+
+
+
+
+
+
+
+
+ 4.0
+
+
+
+
+
+
+
+ MSBuild:Compile
+ Designer
+
+
+ MSBuild:Compile
+ Designer
+
+
+ App.xaml
+ Code
+
+
+
+ MainWindow.xaml
+ Code
+
+
+
+
+ Code
+
+
+ True
+ True
+ Resources.resx
+
+
+ True
+ Settings.settings
+ True
+
+
+ ResXFileCodeGenerator
+ Resources.Designer.cs
+
+
+ SettingsSingleFileGenerator
+ Settings.Designer.cs
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/WechatMediaRenamer/binoculars.png b/WechatMediaRenamer/binoculars.png
new file mode 100644
index 0000000..c375101
Binary files /dev/null and b/WechatMediaRenamer/binoculars.png differ
diff --git a/WechatMediaRenamer/hnet.com-image.ico b/WechatMediaRenamer/hnet.com-image.ico
new file mode 100644
index 0000000..67e18c2
Binary files /dev/null and b/WechatMediaRenamer/hnet.com-image.ico differ