Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: XP Dates & Batch files...  (Read 5113 times)

0 Members and 1 Guest are viewing this topic.

gryghost

  • Guest
XP Dates & Batch files...
« on: June 13, 2005, 09:08:04 PM »
I am trying to create a log file based on the date the batch file is run.

I have searched through your forums and have found this code:
Quote
for /f "tokens=1-4 delims=/ " %%i in ('date /t') do (
 set mm=%%j
 set dd=%%k
 set yy=%%l
)
set TodayDir="c:\Documents %mm%-%dd%-%yy%"


Problem I am having with this code is that the variables are returning with a space on the end of the number.  Instead of getting 20050613, I am getting 2005 06 13.

Is there any way to remove this extra space from the variable?  If I was doing this in VB it's a simple function.

Thanks for any help that you can offer.

Sidewinder



    Guru

    Thanked: 139
  • Experience: Familiar
  • OS: Windows 10
Re: XP Dates & Batch files...
« Reply #1 on: June 14, 2005, 05:10:23 AM »
You're right. When you write the code:
Quote
for /f "tokens=1-4 delims=/ " %%i in ('date /t') do (  
 set mm=%%j  
 set dd=%%k  
 set yy=%%l  
)  
set TodayDir="c:\Documents %mm%-%dd%-%yy%"


I get the results you posted. When I write the code:
Code: [Select]

for /f "tokens=1-4 delims=/ " %%i in ('date /t') do (
set mm=%%j
set dd=%%k
set yy=%%l
)
set TodayDir="c:\Documents %mm%-%dd%-%yy%"

I get the correct result with no embedded spaces.

I notice however, when you write the code the file is 151 bytes and when I write it, it's 141 bytes!! Something is amiss. What editor are you using? What OS? And where did those 10 bytes come from?

VB has date functions that batch can never hope to duplicate. When dealing with dates or any other calculations Script is a better choice.

Hope this helps.
8)
The true sign of intelligence is not knowledge but imagination.

-- Albert Einstein

gryghost

  • Guest
Re: XP Dates & Batch files...
« Reply #2 on: June 14, 2005, 07:50:38 AM »
I am using WinXP SP2.  The editor I was using was notepad.

After reading your reply, I opened a 'dos' window and tried the 'edit' command.  I then tested the new batch file and it didn't have the embedded spaces.  So it seems that the problem had something to do with the way that notepad was saving the file.

Thanks for all your help..  :)

JelloConcoction

  • Guest
Re: XP Dates & Batch files...
« Reply #3 on: June 14, 2005, 10:04:55 AM »
I'm trying to create a new boot drive and when I use the boot disk the program starts but it is interrupted with this message:

Command or filename not recognized
Batch files nested too deeply

Anyone know how I can un"nest" these batch files?

Another thing, however, is that sometimes that message does not come up and the copying process begins.  However that process is halted due to a file copy error.

Could these nested batch files be causing the copy error?
If not what else could it be? ???

Sidewinder



    Guru

    Thanked: 139
  • Experience: Familiar
  • OS: Windows 10
Re: XP Dates & Batch files...
« Reply #4 on: June 14, 2005, 10:39:33 AM »
JelloConcoction,

Are you the same person as the original poster? If not please do not piggyback on someone else's thread. Start your own post.

Your post is too general for a specific reply. Please post your batch file.

There used to be a limit on how many levels of batch calls you could make. What OS are you using?

It's doubtful the copy problem is related, unless of course a file is missing or you are trying to use a invalid or corrupt media.

Get back to us. 8)
The true sign of intelligence is not knowledge but imagination.

-- Albert Einstein

JelloConcoction

  • Guest
Re: XP Dates & Batch files...
« Reply #5 on: June 14, 2005, 11:58:36 AM »
Oops... sorry, I didn't know...

And thanks for the help even though I can't be of anymore help since I don't know the batch file...
(I'm using Windows XP)

And I'll keep your advice for the future! ;)