Create folders based on the file name and move these files to this folder

I am starting to create automated tasks. I need to create folders based on the file name and move these files to this folder. There are instructions, but I'm a little afraid to try ... help a little?

-one
file filenames folders
source share
1 answer

Divide this into two steps (suppose using C++ on a 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 newly created folder (as usual).

0
source share

All Articles