batch script to add remove prefix zero pad bulk file rename
This post has two batch scripts: 1. Batch script to rename files with zero padded number series-prefix 2. Batch script to remove prefix of perticular length 1. Batch script to…
Browsing Tag
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>