回复 4楼 TonyDeng
本掌柜牺牲形象,抛砖引玉,给热爱C语言的大侠们引出一个C语言小项目,希望可以有更多的人加入讨论,结果很失败啊
@echo off&setlocal enabledelayedexpansion for %%b in (jpg) do ( if exist "*.%%b" ( set a=1 for /f "delims=" %%i in ('dir /a-d/b *.%%b') do ( if !a! lss 1000 ( if !a! lss 100 ( if !a! lss 10 ( set R1=000!a! ) else set R1=00!a! ) else set R1=0!a! ) else set R1=!a! if not exist "XX!R1!.%%b" ren "%%i" "XX!R1!.%%b" set /a a+=1 ))) exit该批处理在xp下验证通过,可处理最多9999编号)。
#include "stdafx.h" using namespace System; using namespace System::IO; int main(array<String^>^ args) { array<String^>^ files = Directory::GetFiles(Directory::GetCurrentDirectory(), "*.*", SearchOption::TopDirectoryOnly); for each (String^ filename in files) { FileInfo^ file = gcnew FileInfo(filename); Console::WriteLine(file->Name); // file->MoveTo("新文件名"); } Console::Write("Press any key to continue..."); Console::ReadKey(true); return 0; }