This procedure will split a “;” separated column in to new fields preserving ids. This is very specific problem, lets check it with example. Consider a sample table test: And…
Well procedures mainly carried out working with information schema and it’s usage in stored procedure. Procedures are fairly simple and easy to understand. 1. Edit_table – following procedure executes queries to…
Having a colourful display on shell script is something that’d beautify your experience. Using colour text and echos will help you to highlight and distinguish the shell output on a…
Using Vlookup: I have two csv files; File1 has Id and Value Columns and File2 has Id. Problem: I need to compare both files and put respective values to File2…
In batch scripting, generating file and directory names with current date and time stamps can greatly enhance organization and workflow. This tutorial will walk you through various code snippets and…
4 responses to “bat – batch file to create formatted date time (ddmmyyyy) directory”
Day Month Year Time
dd/mm/yr hh:mm batch file
Hello, I need to develop an batch file where in it will read all the dates (in dd/mm/yy format) and give me output based upon different month.
Input : Excel File (With multiple sheets)
Output: Excel (Preferred)
For a quick start we can start with single sheet, and may be a workbook later.
Now, how do I copy files to these newly created folders using the same batch file? Here’s my batch file so far;
_____________________________________________________
@echo off
C:
CD\
If exist “c:\Master King Backup\” echo Master King Backup folder already exists
If not exist “C:\Master King Backup\” echo Creating Directory
If not exist “C:\Master King Backup\” MD “Master King Backup”
If not exist “C:\Master King Backup\Backup” MD “C:\Master King Backup\Backup”
If not exist “C:\Master King Backup\Working” MD “C:\Master King Backup\Working”
CD\”Master King Backup\Working\”
for /f “usebackq tokens=1-3” %%a in (`date /t`) do (
for /f “delims=/ tokens=1-3” %%i in (“%%b”) do (
for /l %%m in (1,1,50) do (
if exist %%i-%%j-%%k-%%m (
rem do nothing
) else (
mkdir %%i-%%j-%%k-%%m
cd %%i-%%j-%%k-%%m
goto finis
)
)
)
)
:finis
rem do stuff in our directory here like copy some files
rem copy c:\temp\*.*
xcopy /E /C /F /R /Y “C:\Program Files (x86)\HPCSoft\MasterKing32\Database\*.*” “C:\Master King Backup\Working\”
xcopy /E /C /F /R /Y “C:\Master King Backup\Working\” “\\readyshare\USB_Storage\Master King Backup\working\”
CD\”Master King Backup\Backup\”
for /f “usebackq tokens=1-3” %%a in (`date /t`) do (
for /f “delims=/ tokens=1-3” %%i in (“%%b”) do (
for /l %%m in (1,1,50) do (
if exist %%i-%%j-%%k-%%m (
rem do nothing
) else (
mkdir %%i-%%j-%%k-%%m
cd %%i-%%j-%%k-%%m
goto finis
)
)
)
)
:finis
rem do stuff in our directory here like copy some files
rem copy c:\temp\*.*
xcopy /E /C /F /R /Y “C:\Program Files (x86)\HPCSoft\MasterKing32\Database\*.*” “C:\Master King Backup\Backup\”
xcopy /E /C /F /R /Y “C:\Master King Backup\Working\” “\\readyshare\USB_Storage\Master King Backup\Backup\”
_____________________________________________________
Here’s what has to happen, when I run the batch file, I need it to create a new directory and name it (them) the current date and time. Next I need to copy some files on the local computer to the newly created directory(s). Can someone help me with this? Thank you so very much.
You may also see this method given in the following location.
<a href=”http://tips.deepumohan.com/2011/09/windows-batch-script-to-create.html” rel=”nofollow”>Windows batch script for creating directory ddmmyyy</a>