基本信息
源码名称:批量修改视频文件的名字 工具源码
源码大小:0.04M
文件格式:.rar
开发语言:C#
更新时间:2016-10-30
   友情提示:(无需注册或充值,赞助后即可获取资源下载链接)

     嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):78630559

本次赞助数额为: 2 元 
   源码介绍
我们使用迅雷等工具下载完几十集电视剧后,名字中可能有很多没用的信息,例如网址等,我们把视频导入手机后,想看第几集都费劲,所以我就写了这个程序来批量改名。生活中经常用到。


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;

namespace ChangeFileName
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void btnOk_Click(object sender, EventArgs e)
        {
            if (this.lableDir.Text == string.Empty)
            {
                MessageBox.Show("请选择文件夹路径!");
            }
            else if (this.tbOldName.Text == string.Empty)
            {
                MessageBox.Show("请输入旧文件名!");
            }
            else
            {
                try
                {
                    string filePath = this.lableDir.Text;
                    DirectoryInfo theFolder = new DirectoryInfo(filePath);
                    FileInfo[] fis = theFolder.GetFiles();
                    foreach (FileInfo fi in fis)
                    {
                        string newName = fi.Name.Replace(this.tbOldName.Text, this.tbNewName.Text);
                        string newPathName = Path.Combine(this.lableDir.Text, newName);
                        fi.MoveTo(newPathName);
                    }
                    MessageBox.Show("改名完成!");
                }
                catch (Exception ex)
                {
                    MessageBox.Show("批量改名失败,请查找原因!", "提醒", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
        }

        private void btnCancle_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void tbnDir_Click(object sender, EventArgs e)
        {
            FolderBrowserDialog fbd = new FolderBrowserDialog();
            if (fbd.ShowDialog() == DialogResult.OK)
            {
                this.lableDir.Text = fbd.SelectedPath;
            }
        }
    }
}