AutoTidyMyFiles

大学时爱看电影,

记录了很多截图文件,

今日闲来无事,

写了一个,正好记录下

AutoTidyMyFiles

作用是将多个目录下的同一部电影的截图文件统一剪切到自己电影名的目录下,

这里有很多特殊情况的特殊处理,

且目录,文件名需要整理

推荐使用TotalCommander和正则表达式来进行处理:

 

  1// AutoTidyMyFiles.cpp : Defines the entry point for the console application.
  2//
  3  4 #include "stdafx.h"
  5 #include "windows.h"
  6 #include <iostream>
  7 #include <string>
  8 #include <vector>
  9 
 10 using namespace std;
 11 
 12 string GOutPutDir;
 13 int GCount;
 14 struct sFile
 15 {
 16     string strShortName;
 17     string strDir;
 18 };
 19 
 20 void AutoTidy(char * lpPath)
 21 {
 22     char szFind[MAX_PATH];
 23     char szFile[MAX_PATH];
 24     vector<sFile > vecNameList; 
 25     vector<sFile >::iterator iter;
 26     string strTarget;
 27     string strShortName;
 28     long result;
 29     WIN32_FIND_DATA FindFileData;
 30 
 31     strcpy(szFind,lpPath);
 32     strcat(szFind,"\\*.*");
 33 
 34     HANDLE hFind=::FindFirstFile(szFind,&FindFileData);
 35     if(INVALID_HANDLE_VALUE == hFind)    
 36         return;
 37     while(TRUE)
 38     {
 39         if(FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
 40         {
 41             if(FindFileData.cFileName[0]!='.')
 42             {
 43                 strcpy(szFile,lpPath);
 44                 strcat(szFile,"\\");
 45                 strcat(szFile,FindFileData.cFileName);
 46                 AutoTidy(szFile);
 47             }
 48         }
 49         else
 50         {
 51             bool bNeedBuild=true;
 52             //cout << FindFileData.cFileName;
 53             strShortName=FindFileData.cFileName;
 54             strShortName=strShortName.substr(0,9);
 55             //确定当前文件具体地址
 56             strcpy(szFile,lpPath);
 57             strcat(szFile,"\\");
 58             strcat(szFile,FindFileData.cFileName);
 59             if( ! vecNameList.empty() )
 60             {
 61                 for( iter=vecNameList.begin();iter!=vecNameList.end();++iter )
 62                 {
 63                     if( iter->strShortName == strShortName )
 64                     {
 65                         strTarget=iter->strDir+FindFileData.cFileName;
 66                         //剪切过去
 67                         result=MoveFileA(szFile,strTarget.c_str() );
 68                         if0==result )
 69                             cout<<"==Failed toMoveFile:"<<FindFileData.cFileName<<endl;
 70                         bNeedBuild=false;
 71                     }
 72                 }
 73             }
 74             if( bNeedBuild )
 75             {
 76                 sFile tFile;
 77                 string sDir;
 78                 tFile.strShortName=strShortName;
 79                 //以找到的第一个文件作为文件名
 80                 sDir=FindFileData.cFileName;
 81                 sDir=sDir.substr(0,sDir.find_last_of("["));
 86                 tFile.strDir=GOutPutDir+string("/")+sDir+string("/");
 87                 //填入vecNameList
 88                 //建立一个目录 
 89                 result=CreateDirectoryA(tFile.strDir.c_str(),NULL);
 90                 //将自己剪切过去
 91                 strTarget=tFile.strDir+FindFileData.cFileName;
 92                 if0==result )
 93                 {
 94                     //直接放到根目录下
 95                     tFile.strDir=GOutPutDir;
 96                     cout<<"==*Failed to Build Dir:"<<sDir<<endl;
 97                 }
 98                 else
 99                 {
100                     cout<<"==Build Dir:"<<sDir<<endl;
101                     MoveFileA(szFile, strTarget.c_str());
102                 }
103                 vecNameList.push_back( tFile );
104             }
105         }
106         if(!FindNextFile(hFind,&FindFileData))   
107             break;
108     }
109     GCount+=vecNameList.size();
110     FindClose(hFind);
111 }
112 
113 int _tmain(int argc, _TCHAR* argv[])
114 {
115     GCount=0;
116     char szDir[]="O:/The KMPlayer";
117     GOutPutDir=szDir+string("2");
118     AutoTidy(szDir);
119     int i;
120     cin>>i;
121     return 0;
122 }

转载于:https://www.cnblogs.com/Zephyroal/archive/2012/11/03/2753073.html

内容概要:文章详细介绍了渤海大学首胜队参加第九届“飞思卡尔”杯全国大学生智能汽车竞赛的情况。该竞赛涵盖控制、模式识别、传感技术、电子、电气、计算机、机械等多个学科,旨在推动汽车智能化技术的发展。文中首先阐述了智能汽车的研究背景及其重要性,强调智能化是未来汽车发展的趋势。接着介绍了基于MK60DN512VLQ10微处理器的智能车设计方案,包括机械设计(悬挂、轮胎、舵机等)、电路设计(电源管理、电机驱动、红外检测、摄像头、编码器等)和动作设计(腾空飞跃、漂移过弯、走双边桥、过转盘、侧边行车、漂移入位)。文章还展示了系统框图,详细列出了各模块的功能和连接方式。最后总结了团队在整个项目中的收获,包括遇到的问题、解决方案以及团队协作的经验。 适合人群:对智能汽车竞赛感兴趣的学生和技术爱好者,尤其是参与类似竞赛或研究项目的人员。 使用场景及目标:①帮助读者了解智能汽车竞赛的具体流程和技术要求;②为准备参加此类竞赛的团队提供参考案例和技术支持;③展示如何将多学科知识融合应用于实际工程项目中。 其他说明:本文不仅提供了详细的硬件设计和软件编程指导,还分享了团队在比赛过程中积累的经验教训,强调了团队合作的重要性。此外,文章附有详细的参考文献列表,方便读者进一步查阅相关资料。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值