make batch file that creates a folder with today's date then moves files from a folder in to that newly created folder

前端 未结 6 1032
抹茶落季
抹茶落季 2021-01-06 09:56

I need to make a batch file that will make a folder with today\'s date in month day year format (example 080112). Then once it\'s created i need to move files from a set fol

6条回答
  •  日久生厌
    2021-01-06 10:23

    This will show you how to set the date in variables.

    The rest is just using copy/xcopy to that folder :)

    Tell me if you need more elaboration on how to do it.

    Cheers!

    [EDIT]: Here is the complete solution:

    Create a file using notepad -> save as "something.bat" OR using CMD -> copy con something.bat (and once you're done press Ctrl-Z) And paste the following code:

    @echo off
    IF "%1"=="" GOTO MissingArgument
    for /f "tokens=2-4 delims=/ " %%a in ('date /T') do set year=%%c
    for /f "tokens=2-4 delims=/ " %%a in ('date /T') do set month=%%a
    for /f "tokens=2-4 delims=/ " %%a in ('date /T') do set day=%%b
    set TODAY=%month%%day%%year%
    md %TODAY%
    MOVE %1\*.* %TODAY%
    GOTO end
    :MissingArgument
    echo Incorrect Syntax: Source Folder Name Required!
    :end
    

    Hope this helps!

提交回复
热议问题