windows - How to automatically create folder with name being current day and move existing files and subfolders into that folder? -


i need simple tool repeating job. wrote commands in text file , saved file *.bat file.

  1. create new folder current day in month folder name.

    example: today 13-11-14 (format date: dd-mm-yy)

    md=%date:~0.2%

    created folder: 13

  2. move existing files or folders folder 13.

    example:

    before batch file execution current folder contains:

    • folder a
    • folder b
    • file c
    • file d

    after batch file execution current folder should contain:

    • 17
      • folder a
      • folder b
      • file c
      • file d

i drew image show need.

i don't know how write second part of task.

which commands needed move files , subfolders in current folder new folder name of current day in month?

okay, here small batch file task comments , check.

@echo off rem name of batch file in case of being in current directory, too. rem verified if batch file executed in current directory. set "batchfilename=" if "%~dp0"=="%cd%\" set "batchfilename=%~nx0"  rem current day of month. works date formats beginning day. set "day=%date:~0,2%"  rem create directory if not exist. if not exist "%day%" mkdir "%day%"  rem move subdirectories except directory of current day. /d %%d in (*) if not "%%d"=="%day%" move /y "%%d" "%day%"  rem move files except running batch file. %%f in (*) if not "%%f"=="%batchfilename%" move /y "%%f" "%day%"  rem delete 2 environment variables used task. set "batchfilename=" set "day=" 

the of used commands can read in command prompt window after entering:

  • help if or if /?
  • help for or for /?
  • help set or set /?
  • help move or move /?
  • help mkdir or help md or mkdir /? or md /?

Comments

Popular posts from this blog

c++ - QTextObjectInterface with Qml TextEdit (QQuickTextEdit) -

javascript - angular ng-required radio button not toggling required off in firefox 33, OK in chrome -

xcode - Swift Playground - Files are not readable -