
今天正好有个朋友找我帮忙,写个小程序,实现如下需求,
将一批图片文件按照excel中的格式进行文件名修改,原文件名要从excel中的F列获取,修改的文件名要从excel中的H列获取,大概就这么个需求,


我先将需求发给gp4,请看截图


gpt4解释得倒是很详细,可惜代码运行后不能没有达到需求。
这时,我想起了claude3,同样的需求我发给了claude3,(Opus模型,这个模型是最强大的).

不过它的代码,只改了我的第2行, 其他行没改,我继续问它

然后我运行它给的代码,这次运行正常了。下面是完整代码
cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Windows.Forms;
using Excel = Microsoft.Office.Interop.Excel;
namespace foryutao
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
string excelFilePath = @"C:\temp\123.xlsx";
string folderPath = @"C:\temp\123\";
Excel.Application excelApp = new Excel.Application();
Excel.Workbook workbook = excelApp.Workbooks.Open(excelFilePath);
Excel.Worksheet worksheet = workbook.Sheets[1];
try
{
int lastRow = worksheet.Cells.SpecialCells(Excel.XlCellType.xlCellTypeLastCell).Row;
for (int i = 2; i <= lastRow; i++)
{
string oldFileName = worksheet.Cells[i, 6].Value?.ToString();
string newFileName = worksheet.Cells[i, 8].Value?.ToString();
if (!string.IsNullOrEmpty(oldFileName) && !string.IsNullOrEmpty(newFileName))
{
string oldFilePath = Path.Combine(folderPath, oldFileName + ".jpg");
string newFilePath = Path.Combine(folderPath, newFileName + ".jpg");
if (File.Exists(oldFilePath))
{
File.Move(oldFilePath, newFilePath);
}
}
}
MessageBox.Show("文件重命名完成!");
}
catch (Exception ex)
{
MessageBox.Show("发生错误:" + ex.Message);
}
finally
{
workbook.Close();
excelApp.Quit();
}
}
}
}
程序运行界面如下:

点这个按钮就可以实现这个功能。
结论:如果只是写个小项目或者小程序的功能,目前看下来确实是claude3比gpt4更强大,其他方面还没做比较,另外目前claude3太难注册了,分享一个网站给朋友们试用一下:
一定要选opus模型,claude3有三个模型,只有opus是最强大的。