1.

Solve : ADD DATE TO FOLDER NAME?

Answer»

This probably sounds like a bit of an odd question but I am looking to add the date to a folder name with a batch file. The reason for this is so that I can have it set to a schedule to run every day. The over all TASK is to put the date onto a folder name and then the program recreates the previous folder and fills it and then the next day at the same time this script runs again and everyone is HAPPY. The problem I am having is when I use the SET %DATE% command and try add its results to the folder is tells me that the MON or TUE or what ever the day is not a valid function. Is there another way to write this? Any help would be great.

If more information is needed please ask.

Thanks.
perhaps you could show us the batch code you have been using?
Sorry I decided to change accounts to keep some things consistent but the code is shown below:


SET %DATE%

rename \\PCNAME\D$\TEST\ \\PCNAME\TEST%DATE%\

I know this looks very BASIC but I am still learning the scripting world. Thanks for the help.
try here---> http://talk.bmc.com/blogs/blog-gentle/anne-gentle/dos-timestamp-tipsThank You very much gumbaz. That got me the date and time variable. Unfortunately I am unable to rename the file with that variable. I have tried with the URL path & Mapping a network drive with no success. I have tried using the xcopy, REN, and other commands to try to change the name with the variable with no success. Any ideas?Quote


SET %DATE%


I'm not sure what that line is meant to do. LOSE it! To set a variable, you don't use percent signs. To read it you do. For example

set food=eggs
echo %food%

Also if you want to read the value of %date%, you should not be trying to set it.

Use quotes around any file, folder or path containing spaces.

Quote

rename "\\PCNAME\D$\TEST" "\\PCNAME\TEST%DATE%"



I was missing the "" . Stupid mistake. The entire script looks like so:


REM Create sub directory CALLED \yymmdd_hhmmss

REM where yymmdd_hhmmss is a date_time stamp like 030902_134200

set hh=%time:~0,2%

REM Since there is no leading zero for times before 10 am, have to put in

REM a zero when this is run before 10 am.

if "%time:~0,1%"==" " set hh=0%hh:~1,1%

set yymmdd_hhmmss=%date:~12,2%%date:~4,2%%date:~7,2%_%hh%%time:~3,2%%time:~6,2%

MOVE "\\PCNAME\D$\TEST" "\\PCNAME\D$\TEST%yymmdd_hhmmss%"


Thanks for the help Guys/Girls

--I have alot of learning to do--


Discussion

No Comment Found