computing
  • 10

Solved Batch File To Create Folder With Y’day Date??

  • 10

hi guys,

i want to create a folder with naming as yesterday date.can anyone help me out.i require dis to do my office work as daily task.plz help me

Share

1 Answer

  1. It could be normal to format the date in yyyymmdd format for naming folders/files but you don’t specify what format is required or what your current system date format is. The following will hopefully create a folder in your current system date format, it is assumed that your date separator is currently forward slash (/).

    @echo off
    setlocal enabledelayedexpansion
    cls
    
    set vbs=%temp%\vbs.vbs
    
    > %vbs% echo WScript.Echo DateAdd("d",-1,Date)
    
    for /f "tokens=* delims=" %%a in ('cscript //nologo %vbs%') do (
        set newfold=%%a&set; newfold=!newfold:/=-!
        md "!newfold!"
        echo New folder created !newfold!
    )
    
    

    Please come back & tell us if your problem is resolved.

    • 0