Remove / and : in strings

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
phillid
Posts: 109
Joined: 03 Apr 2010 20:27
Location: Wellington, New Zealand
Contact:

Remove / and : in strings

#1 Post by phillid » 04 Aug 2010 23:31

Hello again. I am using the %date% and %time% variables in a program, but I need to take the / and the : out of them to leave me with just a number like 21072010. I know that I need to use a FOR loop, but I'm still working on how to use them.
Thanks, guys. :D
phillid

!k
Expert
Posts: 378
Joined: 17 Oct 2009 08:30
Location: Russia

Re: Remove / and : in strings

#2 Post by !k » 05 Aug 2010 02:07

Read set/?

Code: Select all

set "var=%var:/=%"

jeb
Expert
Posts: 1055
Joined: 30 Aug 2007 08:05
Location: Germany, Bochum

Re: Remove / and : in strings

#3 Post by jeb » 05 Aug 2010 04:29

Or you can use it like

Code: Select all

set now=%time%
echo %now:~0,2%_%now:~3,2%_%now:~6,2%


Also, you can read about it with set /? :wink:

Post Reply