private void button1_Click(object sender, EventArgs e) { //只判断处理文件夹 foreach (string path in this.listBoxNameSet.Items) { if (Directory.Exists(path)) { string NewName = path.Substring(path.LastIndexOf("\\") + 1); string NewPath = path.Remove(path.LastIndexOf("\\")); List <string> file = CodeAll.ScanVideo(path, "*", SearchOption.AllDirectories); if (file.Count != 1) { continue; } if (File.Exists(NewPath + "\\" + NewName + Path.GetExtension(file[0]))) { continue; } try { File.Move(file[0], NewPath + "\\" + NewName + Path.GetExtension(file[0])); Directory.Delete(path, true); } catch (Exception ex) { CodeAll.AddLog("移动失败", path, ex.Message); } } } }
private void listBoxFile_DragDrop(object sender, DragEventArgs e) { string[] s = (string[])e.Data.GetData(DataFormats.FileDrop, false); foreach (string o in s) { //搜索拖入的路径,是目录,扫描视频文件 if (System.IO.File.Exists(o)) { if (CodeAll.isVideo(o)) { this.listBoxFile.Items.Add(o); } } else if (System.IO.Directory.Exists(o)) { List <string> lst = CodeAll.ScanVideo(o, "*", SearchOption.AllDirectories); foreach (var item in lst) { this.listBoxFile.Items.Add(item); } } } }
private void button22_Click(object sender, EventArgs e) { //只处理文件夹 string WorkPath = setting.ConcatVideoPath; System.IO.Directory.CreateDirectory(WorkPath); string txtLst = ""; string txtSh = ""; int index = 0; foreach (string folder in listBoxNameSet.Items) { if (!Directory.Exists(folder)) { continue; } List <string> files = CodeAll.ScanVideo(folder, "*", SearchOption.TopDirectoryOnly); if (files.Count < 2) { continue; } files.Sort(); string txtConcat = ""; txtLst += folder + "\r\n"; foreach (string file in files) { txtLst += "\t\t" + System.IO.Path.GetFileName(file) + "\r\n"; txtConcat += "file '" + ConcatTransFolder(file) + "'\n"; } DLL.TxtStr.Write(txtConcat, WorkPath + index.ToString() + ".txt", true, new System.Text.UTF8Encoding(false)); txtSh += "ffmpeg -f concat -safe 0 -i " + index.ToString() + ".txt" + " -c copy " + " '" + ConcatTransFolder(folder) + "/all" + System.IO.Path.GetExtension(files[0]) + "'\n"; txtSh += "chmod 777 '" + ConcatTransFolder(folder) + "/all" + System.IO.Path.GetExtension(files[0]) + "'\n"; index++; } DLL.TxtStr.Write(txtSh, WorkPath + "x.sh", true, new System.Text.UTF8Encoding(false)); DLL.TxtStr.Write(txtLst, WorkPath + "lst.txt", true); }