1.

Solve : date and time in filename why whont this work :-??

Answer»

i want to make the date and time be the name of my output file LIKE this whta is wrong
Code: [Select]set/p file=Type default and the name will be test-date-time:
for /f "tokens=1-2 delims= " %%i in ('time /t') do set time1=%%i
if %file% equ default set file=file2
set file2=IPget-%date:~4,6%%date:~12,2%-%time1%
echo it worked>>%file%
any help???Well for ONE thing, the statements are incorrectly sequenced. You cannot use a variable (file2) before it has a value. You also need to reference it as a variable. The code below only fixes the sequence problem.

Code: [Select]set/p file=Type default and the name will be test-date-time:
for /f "tokens=1-2 delims= " %%i in ('time /t') do set time1=%%i
set file2=IPget-%date:~4,6%%date:~12,2%-%time1%
if %file% equ default set file=%file2%
echo it worked>>%file%

The other problem is that file2 has embedded forward slashes which imply a directory structure that does not exist. (IPget-05/14/06-03:44). I'll leave it to you to replace the slashes with dashes.

Keep up the good WORK. 8-)ok think you for that i didint think that the / in the date woould affect it Here is the complete LIST of illegal characters in a file name: / ? < > \ : * | "

Also add to the list any character you can create with the CTRL key.

8-)



Discussion

No Comment Found