You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

70 lines
1.9 KiB

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Apewer.Run
{
class FileRenamer
{
public FileRenamer()
{
// RenameZQSV();
var dir = @"E:\Breaking Bad";
var paths = StorageUtility.GetSubFiles(dir, true);
var array = Json.NewArray();
foreach (var path in paths)
{
var name = Path.GetFileName(path);
if (name.EndsWith(".mkv")) continue;
if (name.EndsWith(".json")) continue;
name = name.Replace("Breaking Bad - ", "");
array.AddItem(name);
name = name + ".srt";
var newPath = Path.Combine(Path.GetDirectoryName(path), name);
if (newPath != path)
{
File.Move(path, newPath);
Console.WriteLine($"{path} -> {newPath}");
}
// else Console.WriteLine(path);
}
StorageUtility.WriteFile(Path.Combine(dir, "info.json"), array.ToString(true).ToBinary());
}
void RenameZQSV()
{
var paths = Apewer.StorageUtility.GetSubFiles("z:\\", true);
foreach (var path in paths)
{
RenameFile(path, " ", "_");
RenameFile(path, "【蓝光1080P】", "");
}
}
void RenameFile(string path, string oldSub, string newSub)
{
if (path.Contains(oldSub))
{
var newName = path.Replace(oldSub, newSub);
File.Move(path, newName);
Console.WriteLine($"{path} -> {newName}");
}
else
{
Console.WriteLine(path);
}
}
}
}