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 folder in to the folder it just created. To be honest i don't know how to make a batch file.
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!
set TODAY=%date:~10,4%%date:~7,2%%date:~4,2%
is an alternative way to get the date part into a shell variable
from: http://stevesgeekspeak.com/2010/01/howto-get-variable-substrings-in-batcmd-scripts/
Jony ... FTW, of course, for having the whole answer.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With