Dos batch file time leading zeros12/17/2023 Works just fine including the 00 hours after midnight. Looks good so far I just noticed today you replied, I'm recording some tv shows so I'll have to wait till 3pm local to start messing with the system clock and test it at various times It would be interesting to see the rest of your code, because this:ĮCHO Will rename the file in the format "200908071137amTest File.txt"ĮCHO In a batch file use CALL STAMPME. If I could get this to work it would solvwe alot of my problems!!!! If %_ap%=PM SET _hr=%_hr%+12(the syntax of the command arrrrrrrrrrrrrrrrg :wall::pc:ĮCHO Today is Year: %_yy% Month: %_mm:~-2% Day: %_dd:~-2% If %_ap%=AM AND _hr=12 SET _hr=00 (I dunno if that would even work) So I'm thinking it would be nice to have a code that converts my am/pm clock to 24 hours but I ran my head against the :wall: with two things so far A: I can't add 12 hours to the _hr variableĪnd B: I dunno if "IF and commands actually work the only way top test that is after midnight (or change your clock but I haven't solved the adding 12 issue yet.įOR /f "tokens=1,2,3 delims=: " %%G IN ('time/t') DO ( yes at times my connection crawls and at other times the files are all retrived with-in a minute. Okies I fixed it so it will write AM or PM in the file and the display, however I still dun like it this is what I did.Īctually the code does work quite contrary to your guarantee.īut I'm still having problems with the windows file order at times the am's and pm's get mixed up because they are of the same date and retrival times differ depending on my connection so a file retrived at 12:11 am may get mixed in with files retrived between 12:10 pm and 12:30 pm. ![]() Well I using the script I found on the website attached just modified some display components.Īlso I see the padding down there I see that somehow it will display it in a way that trunicates the 0 if it's a 2 digit month or day fine now I just need a way to set a variable that will display either am or pm after it retrives it from where ever my script retieves it's timeĪctually I fixed the am/pm thing but I still got a few problems look at both code pieces below Wait a minute that link is to this post :S You'd be better off using this script to figure out the components of the date - it works independently of the regional date setting, or so it claims. ![]() (untested, only showing the changed code): However, to answer your question, you'll need to pad the month, day, and hour with zeros. I have to agree that this isn't the best script in the world. ![]() Well, it's still not using the best method to get the date components. ]ĮDIT: Oops, that's not your script is it. I don't really understand why you're using "net time" to get the date - you're making your life more difficult than it needs to be. :: note ISO 8601 date format would require 4 digit YYYY Year)įOR /f "tokens=6-8 delims=/ " %%G IN ('NET TIME \\%computername%') DO (įOR /f "tokens=1,2 delims=: " %%G IN ('time/t') DO (ĮCHO Today is Year: Month: Day: :: To change the filename format just change around the last line below ECHO Will rename the file in the format "Test In a batch file use CALL STAMPME.
0 Comments
Leave a Reply.AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |