64,676
社区成员
发帖
与我相关
我的任务
分享
for %%f in (c:\test\*.*) do (if not %%~xf==.txt del "%%f")
BOOL GetFileFirstShowPage(CString strFolderPath)
{
BOOL ret = FALSE;
int dFolderNum = 0;
CString strDeleteFolder;
WIN32_FIND_DATA FindFileData;
HANDLE hFind = INVALID_HANDLE_VALUE;
CString strFolderPathAll = strFolderPath + L"\\*.*";
hFind=::FindFirstFile(strFolderPathAll,& FindFileData);
do
{
IF_BREAK(hFind == INVALID_HANDLE_VALUE);
if(FindFileData.cFileName[0]=='.') //过滤本级目录和父目录
continue;
if(FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) //如果找到的是目录,则进入此目录进行递归
{
GetFileFirstShowPage(strFolderPath + FindFileData.cFileName + L"\\");
}
else
{
CString strShortName = FindFileData.cFileName;
int posEnd = strShortName.ReverseFind('.');
if (posEnd != -1)
{
strShortName = strShortName.Mid(posEnd + 1);
}
if (strShortName.CompareNoCase(L"txt") == -1)
{
Cstring strFilePath = strFolderPath + FindFileData.cFileName;
//删除文件操作
ret = TRUE;
}
}
}while(::FindNextFile(hFind,& FindFileData));
return ret;
}