请问 怎么样 才能 把 给出一个目录  要求 把所有 扩展名为 .rmvb的文件 改成 .avi?此目录下 可能含有其他格式文件  但是只要求修改 .rmvb的文件  请问怎么处理 ?   

解决方案 »

  1.   

    大哥 请写详细点可以吗?  我是一个菜鸟  什么都不会那void fun(CString path);//path为目录路径请大哥多多指教 !
      

  2.   

    use CFileFind;void Rename(CString strPath)
    {
    CFileFind finder;
    strPath+=_T("\\*.*");
    if (finder.FindFirst(strPath))
    {
     BOOL bContinue=TRUE;
     while (bContinue)
     {
        CString strFile;
        bContinue=finder.FindNextFile(strFile);
        if (finder.IsDirectory()==FALSE)
        {
         MyRenameFunc(finder.GetPathName());
        }
      }
     }相关函数:
    PathGetFileName(); 
    PathRemoveExtention();
      

  3.   

    上边的哥哥 没告诉我 怎么判断 是否为 .rmvb的文件啊 其他的文件也不需要修改啊
      

  4.   

    void Rename(CString strPath)
    {
    CFileFind finder;
    strPath+=_T("\\*.*");
    if (finder.FindFirst(strPath))
    {
     BOOL bContinue=TRUE;
     while (bContinue)
     {
        CString strFile;
        bContinue=finder.FindNextFile(strFile);
        if (finder.IsDirectory()==FALSE)
        {
         CString strExtention;
         strExtension=::PathFindExtension(finder.GetPathName());
         if (strExtension.CompareNoCase(_T(".rmvb")==0)
         {
         MyRenameFunc(finder.GetPathName());
         }
        }
      }
     }
      

  5.   

    //这是我临时写出来的,具体调用你还要看看MSDN
    void Rename(CString strPath)
    {
    CFileFind finder;
    strPath+=_T("\\*.*");
    if (finder.FindFirst(strPath))
    {
     BOOL bContinue=TRUE;
     while (bContinue)
     {
        CString strFile;
        bContinue=finder.FindNextFile(strFile);
        if (finder.IsDirectory()==FALSE)
        {
         CString strExtention;
         strExtension=::PathFindExtension(finder.GetPathName());
         if (strExtension.CompareNoCase(_T(".rmvb")==0)
         {
            //MyRenameFunc(finder.GetPathName());
           RenameExtension (finder.GetPathName(),_T(".avi"));
         }
        }
      }
     }
      

  6.   

    具体就是遍历+修改哪
    要想简单点就用DOS命令system("rename d:\\test\\*.rmvb *.avi")
      

  7.   

    谢谢各位帮助 bingo 哥哥的代码 运行错误  继续研究中 ......