根据文件名创建文件夹并将这些文件移动到该文件夹中 [英] create folders based on a file name and move those files into that folder
本文介绍了根据文件名创建文件夹并将这些文件移动到该文件夹中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是创建自动化任务的新手。我需要基于文件名创建文件夹,并将这些文件移到该文件夹中。有说明,但是我有点害怕尝试...一点帮助?
I am a novice in creating automated tasks. I need to create folders based on a file name and move those files into that folder. There are instructions, but I am a little scared to try...little help?
推荐答案
将其分为两个步骤(假设在 Windows
操作系统中使用 C ++
):
Split this into two steps (assume using C++
in Windows
OS):
-
创建文件夹。
Create a folder.
#include <Windows.h>
void create_folder(char* Path)
{
char DirName[256];
char* p = Path;
char* q = DirName;
while(*p)
{
if (('\\' == *p) || ('/' == *p))
{
if (':' != *(p-1))
{
CreateDirectory(DirName, NULL);
}
}
*q++ = *p++;
*q = '\0';
}
CreateDirectory(DirName, NULL);
}
将文件写入您刚刚创建的文件夹(通常做)。
Write the file to the folder you just created (as you normally do).
这篇关于根据文件名创建文件夹并将这些文件移动到该文件夹中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文