69,369
社区成员
发帖
与我相关
我的任务
分享
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <errno.h>
#include <dirent.h>
int main(int argc, char *argv[])
{
if (argc < 2) {
fprintf(stdout, "Usage: too few paramters!\n");
return 0;
}
DIR *dp = NULL;
dp = opendir(argv[1]);
if (!dp) {
fprintf(stderr, "opendir: %s\n", strerror(errno));
return 0;
}
struct dirent *dirp;
while ((dirp = readdir(dp))) {
if (strcmp(dirp->d_name, ".") == 0 || strcmp(dirp->d_name, "..") == 0)
continue;
printf("%s\n", dirp->d_name);
}
closedir(dp);
return 0;
}
系统调用,建议把上面的代码先运行一下,然后改成你想要的--就是把文件名拷贝到你要得缓存里。
@echo off & setlocal EnableDelayedExpansion
for /f "delims=" %%i in ('"dir /a/s/b/on *.*"') do (
set file=%%~fi
set file=!file:/=/!
echo !file! >> 路径.txt
)
bat文件内输入这个,然后把改文件放在你需要的目录下