create folders based on a file name and move those files into that folder

后端 未结 1 682
小鲜肉
小鲜肉 2021-01-29 11:30

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 scare

1条回答
  •  抹茶落季
    2021-01-29 12:28

    Split this into two steps (assume using C++ in Windows OS):

    1. Create a folder.

      #include 
      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);
      }
      
    2. Write the file to the folder you just created (as you normally do).

    0 讨论(0)
提交回复
热议问题