diff --git a/Mk0.Software.ImageSorter/Dateirenamer.Designer.cs b/Mk0.Software.ImageSorter/Dateirenamer.Designer.cs new file mode 100644 index 0000000..c6b3038 --- /dev/null +++ b/Mk0.Software.ImageSorter/Dateirenamer.Designer.cs @@ -0,0 +1,242 @@ + +namespace Mk0.Software.ImageSorter +{ + partial class Dateirenamer + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.label1 = new System.Windows.Forms.Label(); + this.label2 = new System.Windows.Forms.Label(); + this.textBoxSuche = new System.Windows.Forms.TextBox(); + this.textBoxErsetze = new System.Windows.Forms.TextBox(); + this.buttonAusfuehren = new System.Windows.Forms.Button(); + this.buttonSpeichern = new System.Windows.Forms.Button(); + this.groupBox1 = new System.Windows.Forms.GroupBox(); + this.groupBox2 = new System.Windows.Forms.GroupBox(); + this.button5 = new System.Windows.Forms.Button(); + this.button4 = new System.Windows.Forms.Button(); + this.button3 = new System.Windows.Forms.Button(); + this.groupBox3 = new System.Windows.Forms.GroupBox(); + this.textBoxLog = new System.Windows.Forms.TextBox(); + this.checkBoxRekursiv = new System.Windows.Forms.CheckBox(); + this.groupBox1.SuspendLayout(); + this.groupBox2.SuspendLayout(); + this.groupBox3.SuspendLayout(); + this.SuspendLayout(); + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(6, 16); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(71, 13); + this.label1.TabIndex = 0; + this.label1.Text = "Suchen nach"; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(6, 69); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(64, 13); + this.label2.TabIndex = 1; + this.label2.Text = "Ersetzen mit"; + // + // textBoxSuche + // + this.textBoxSuche.Location = new System.Drawing.Point(6, 35); + this.textBoxSuche.Name = "textBoxSuche"; + this.textBoxSuche.Size = new System.Drawing.Size(182, 20); + this.textBoxSuche.TabIndex = 2; + // + // textBoxErsetze + // + this.textBoxErsetze.Location = new System.Drawing.Point(6, 88); + this.textBoxErsetze.Name = "textBoxErsetze"; + this.textBoxErsetze.Size = new System.Drawing.Size(182, 20); + this.textBoxErsetze.TabIndex = 3; + // + // buttonAusfuehren + // + this.buttonAusfuehren.Location = new System.Drawing.Point(6, 155); + this.buttonAusfuehren.Name = "buttonAusfuehren"; + this.buttonAusfuehren.Size = new System.Drawing.Size(75, 23); + this.buttonAusfuehren.TabIndex = 4; + this.buttonAusfuehren.Text = "Ausführen"; + this.buttonAusfuehren.UseVisualStyleBackColor = true; + this.buttonAusfuehren.Click += new System.EventHandler(this.ButtonAusfuehren_Click); + // + // buttonSpeichern + // + this.buttonSpeichern.Location = new System.Drawing.Point(113, 155); + this.buttonSpeichern.Name = "buttonSpeichern"; + this.buttonSpeichern.Size = new System.Drawing.Size(75, 23); + this.buttonSpeichern.TabIndex = 5; + this.buttonSpeichern.Text = "Speichern"; + this.buttonSpeichern.UseVisualStyleBackColor = true; + this.buttonSpeichern.Click += new System.EventHandler(this.ButtonSpeichern_Click); + // + // groupBox1 + // + this.groupBox1.Controls.Add(this.checkBoxRekursiv); + this.groupBox1.Controls.Add(this.label1); + this.groupBox1.Controls.Add(this.buttonSpeichern); + this.groupBox1.Controls.Add(this.label2); + this.groupBox1.Controls.Add(this.buttonAusfuehren); + this.groupBox1.Controls.Add(this.textBoxSuche); + this.groupBox1.Controls.Add(this.textBoxErsetze); + this.groupBox1.Location = new System.Drawing.Point(12, 12); + this.groupBox1.Name = "groupBox1"; + this.groupBox1.Size = new System.Drawing.Size(196, 190); + this.groupBox1.TabIndex = 6; + this.groupBox1.TabStop = false; + this.groupBox1.Text = "Operation"; + // + // groupBox2 + // + this.groupBox2.Controls.Add(this.button5); + this.groupBox2.Controls.Add(this.button4); + this.groupBox2.Controls.Add(this.button3); + this.groupBox2.Location = new System.Drawing.Point(269, 28); + this.groupBox2.Name = "groupBox2"; + this.groupBox2.Size = new System.Drawing.Size(178, 106); + this.groupBox2.TabIndex = 7; + this.groupBox2.TabStop = false; + this.groupBox2.Text = "Gespeicherte Operationen"; + this.groupBox2.Visible = false; + // + // button5 + // + this.button5.Location = new System.Drawing.Point(8, 60); + this.button5.Name = "button5"; + this.button5.Size = new System.Drawing.Size(156, 23); + this.button5.TabIndex = 2; + this.button5.Text = "Alle Ausführen"; + this.button5.UseVisualStyleBackColor = true; + // + // button4 + // + this.button4.Location = new System.Drawing.Point(89, 31); + this.button4.Name = "button4"; + this.button4.Size = new System.Drawing.Size(75, 23); + this.button4.TabIndex = 1; + this.button4.Text = "Ausführen"; + this.button4.UseVisualStyleBackColor = true; + // + // button3 + // + this.button3.Location = new System.Drawing.Point(8, 31); + this.button3.Name = "button3"; + this.button3.Size = new System.Drawing.Size(75, 23); + this.button3.TabIndex = 0; + this.button3.Text = "Löschen"; + this.button3.UseVisualStyleBackColor = true; + // + // groupBox3 + // + this.groupBox3.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.groupBox3.Controls.Add(this.textBoxLog); + this.groupBox3.Location = new System.Drawing.Point(12, 214); + this.groupBox3.Name = "groupBox3"; + this.groupBox3.Size = new System.Drawing.Size(618, 188); + this.groupBox3.TabIndex = 8; + this.groupBox3.TabStop = false; + this.groupBox3.Text = "Logs"; + // + // textBoxLog + // + this.textBoxLog.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.textBoxLog.BackColor = System.Drawing.SystemColors.Window; + this.textBoxLog.Location = new System.Drawing.Point(6, 19); + this.textBoxLog.Multiline = true; + this.textBoxLog.Name = "textBoxLog"; + this.textBoxLog.ReadOnly = true; + this.textBoxLog.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; + this.textBoxLog.Size = new System.Drawing.Size(606, 163); + this.textBoxLog.TabIndex = 0; + // + // checkBoxRekursiv + // + this.checkBoxRekursiv.AutoSize = true; + this.checkBoxRekursiv.Checked = true; + this.checkBoxRekursiv.CheckState = System.Windows.Forms.CheckState.Checked; + this.checkBoxRekursiv.Location = new System.Drawing.Point(6, 123); + this.checkBoxRekursiv.Name = "checkBoxRekursiv"; + this.checkBoxRekursiv.Size = new System.Drawing.Size(68, 17); + this.checkBoxRekursiv.TabIndex = 6; + this.checkBoxRekursiv.Text = "Rekursiv"; + this.checkBoxRekursiv.UseVisualStyleBackColor = true; + // + // Dateirenamer + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(638, 410); + this.Controls.Add(this.groupBox3); + this.Controls.Add(this.groupBox2); + this.Controls.Add(this.groupBox1); + this.MaximizeBox = false; + this.MinimizeBox = false; + this.MinimumSize = new System.Drawing.Size(654, 397); + this.Name = "Dateirenamer"; + this.ShowIcon = false; + this.ShowInTaskbar = false; + this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Dateirenamer"; + this.TopMost = true; + this.Shown += new System.EventHandler(this.Dateirenamer_Shown); + this.groupBox1.ResumeLayout(false); + this.groupBox1.PerformLayout(); + this.groupBox2.ResumeLayout(false); + this.groupBox3.ResumeLayout(false); + this.groupBox3.PerformLayout(); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.Label label1; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.TextBox textBoxSuche; + private System.Windows.Forms.TextBox textBoxErsetze; + private System.Windows.Forms.Button buttonAusfuehren; + private System.Windows.Forms.Button buttonSpeichern; + private System.Windows.Forms.GroupBox groupBox1; + private System.Windows.Forms.GroupBox groupBox2; + private System.Windows.Forms.Button button5; + private System.Windows.Forms.Button button4; + private System.Windows.Forms.Button button3; + private System.Windows.Forms.GroupBox groupBox3; + private System.Windows.Forms.TextBox textBoxLog; + private System.Windows.Forms.CheckBox checkBoxRekursiv; + } +} \ No newline at end of file diff --git a/Mk0.Software.ImageSorter/Dateirenamer.cs b/Mk0.Software.ImageSorter/Dateirenamer.cs new file mode 100644 index 0000000..948b8a8 --- /dev/null +++ b/Mk0.Software.ImageSorter/Dateirenamer.cs @@ -0,0 +1,91 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace Mk0.Software.ImageSorter +{ + public partial class Dateirenamer : Form + { + private string quellPath; + + public Dateirenamer(string quellPath) + { + InitializeComponent(); + this.quellPath = quellPath; + } + + private void Dateirenamer_Shown(object sender, EventArgs e) + { + if (!Directory.Exists(quellPath)) + { + MessageBox.Show("Es wurde kein gültiger Quellpfad definiert. Bitte zuerst definieren, dann erneut versuchen.", "Kein Quellpfad definiert", MessageBoxButtons.OK, MessageBoxIcon.Error); + this.Close(); + } + } + + private void ButtonAusfuehren_Click(object sender, EventArgs e) + { + if (CheckInput()) + { + textBoxLog.Clear(); + Scanner(quellPath, textBoxSuche.Text, textBoxErsetze.Text, checkBoxRekursiv.Checked); + } + } + + private void ButtonSpeichern_Click(object sender, EventArgs e) + { + if (CheckInput()) + { + MessageBox.Show("ok"); + //todo + } + } + + private bool CheckInput() + { + if (string.IsNullOrEmpty(textBoxSuche.Text)) + { + return false; + } + return true; + } + + public void Scanner(string pfad, string suchen, string ersetzen, bool rekursiv = false) + { + DirectoryInfo dir = new DirectoryInfo(pfad); + + foreach (FileInfo file in dir.GetFiles("*.*")) + { + if (file.Name.Contains(suchen)) + { + try + { + string newName = file.Name.Replace(suchen, ersetzen); + textBoxLog.AppendText("RENAME: " + dir.Name + "| " + file.Name + " -> " + newName + Environment.NewLine); + File.Move(Path.Combine(dir.FullName, file.Name), Path.Combine(dir.FullName, newName)); + } + catch (Exception) + { + textBoxLog.AppendText("DELETE: " + dir.Name + "| " + file.Name + Environment.NewLine); + File.Delete(Path.Combine(dir.FullName, file.Name)); + } + } + } + + if (rekursiv) + { + foreach (DirectoryInfo dir2 in dir.GetDirectories()) + { + Scanner(dir2.FullName, suchen, ersetzen, true); + } + } + } + } +} diff --git a/Mk0.Software.ImageSorter/Dateirenamer.resx b/Mk0.Software.ImageSorter/Dateirenamer.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/Mk0.Software.ImageSorter/Dateirenamer.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Mk0.Software.ImageSorter/EXIF.Designer.cs b/Mk0.Software.ImageSorter/EXIF.Designer.cs index 0f02559..06995b8 100644 --- a/Mk0.Software.ImageSorter/EXIF.Designer.cs +++ b/Mk0.Software.ImageSorter/EXIF.Designer.cs @@ -51,7 +51,9 @@ this.MinimizeBox = false; this.Name = "EXIF"; this.ShowIcon = false; + this.ShowInTaskbar = false; this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; this.Text = "EXIF"; this.Shown += new System.EventHandler(this.EXIF_Shown); this.ResumeLayout(false); diff --git a/Mk0.Software.ImageSorter/Main.cs b/Mk0.Software.ImageSorter/Main.cs index 803d4fc..513ea20 100644 --- a/Mk0.Software.ImageSorter/Main.cs +++ b/Mk0.Software.ImageSorter/Main.cs @@ -703,6 +703,11 @@ namespace Mk0.Software.ImageSorter } } + /// + /// Removes the marks from cropping and cutting in filename + /// + /// + /// private string CleanFileName(string filename) { string fn = filename; @@ -1154,7 +1159,7 @@ namespace Mk0.Software.ImageSorter using (Image img = Image.FromFile(pictureBoxImage.ImageLocation)) { EXIF exif = new EXIF(img.PropertyItems); - exif.ShowDialog(); + exif.ShowDialog(this); } } @@ -1613,7 +1618,8 @@ namespace Mk0.Software.ImageSorter /// private void ButtonDateirenamer_Click(object sender, EventArgs e) { - + Dateirenamer dr = new Dateirenamer(quellPath); + dr.ShowDialog(this); } } } \ No newline at end of file diff --git a/Mk0.Software.ImageSorter/Mk0.Software.ImageSorter.csproj b/Mk0.Software.ImageSorter/Mk0.Software.ImageSorter.csproj index b1e1ee2..dc0ef95 100644 --- a/Mk0.Software.ImageSorter/Mk0.Software.ImageSorter.csproj +++ b/Mk0.Software.ImageSorter/Mk0.Software.ImageSorter.csproj @@ -110,6 +110,12 @@ Cropper.cs + + Form + + + Dateirenamer.cs + Form @@ -140,6 +146,9 @@ Cropper.cs + + Dateirenamer.cs + EXIF.cs