We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now


creating julian date with batch file

Medium Priority
Last Modified: 2013-11-10

I am trying to create a batch file to do several things. Somethings i can handle while others i have no clue and have googled all over the place for answers and have come out empty handed.

I need my batch file to do the below:

1. Upload pdf reports to an internal 2003 sharepoint site.
I found a program called davcopy.exe on the internet that does just this http://www.bluedoglimited.com/Downloads/pages/DavCopy.aspx so i am ok with this part of my batch file.

If anyone know of anything easier then this i would be most appreciative.

2. I will then need to back up the raw reports to a folder. I will need the batch file to create a folder with the Julian date of the report and then move all of these reports in to there.

So say my reports are for July 8th 2009 (Julian date: 2009189). Example: Name of report is: "Report1.189 i will need my batch file to create a folder in C:\Reports called 2009189 and then move all of my reports from its current location in to C:\Reports\2009189

Does anyone have any ideas?

If you need me to be more clear on what i want to do please let me know.

Watch Question

Top Expert 2009

That's not really Julian date is it? That's just the number of days in this year?
Jan 31
Feb 28
Mar 31
Apr 30
May 31
Jun 30
Jul 8

How do you currently set your date format?
What is the output using this command?
date /t

Unlock this solution with a free trial preview.
(No credit card required)
Get Preview

The following batch file will calculate the 'JulianDate' (as specified), create the folder 'JulianDate' and move the *.PDF files to the new folder.

Copy and paste the code into Notepad and save as MOVEJD.BAT (or whatever name you choose) in the folder containing your *.PDF files. Then, fire up a DOS session and enter the following command:


NOTE: I leave it to you to do the upload stuff.

rem -------------------------------------------------------------
rem MOVEJD.BAT - Written by Paul Tomasi (t0t0) 2009
rem -------------------------------------------------------------
@echo off
setlocal enabledelayedexpansion

set CurrentDate=%date%
call :GetJD CurrentDate JulianDate

if not exist %JulianDate% md %JulianDate%
if exist *.pdf move /y *.pdf %JulianDate%\ >nul
exit /b

rem -------------------------------------------------------------
rem GETJD - Written by Paul Tomasi (t0t0) 2009
rem -------------------------------------------------------------
set Day=!%1:~0,2!
set Month=!%1:~3,2!
set Year=!%1:~6,4!

for %%i in (1 3 5 7 8 10 12) do set Month[%%i].Days=31
for %%i in (4 6 9 11) do set Month[%%i].Days=30

call :IsLeapYear Year Month[2].Days

set %2=!Day!

if !Month! gtr 1 (
   set /a Month-=1
   for /l %%i in (1,1,!Month!) do (
      set /a %2+=Month[%%i].Days

set %2=00!%2!
set %2=!%2:~-3!
set %2=!Year!!%2!
exit /b

rem -------------------------------------------------------------
rem ISLEAPYEAR - Written by Paul Tomasi (t0t0) 2009
rem -------------------------------------------------------------
set /a mod=!%1! %% 4
if !mod! equ 0 (
   set /a mod=!%1! %% 100
   if !mod! equ 0 (
      set /a mod=!%1! %% 400
      if !mod! equ 0 (
         set %2=29
         exit /b 1
   ) else (
      set %2=29
      exit /b 1
set %2=28
exit /b 0

Unlock this solution with a free trial preview.
(No credit card required)
Get Preview


Not sure if i did this right. I wanted to accept both t0t0's and dnilson's responce. I am not sure why under dnilson it says "Accepted Solution" and under t0t0 solution it says "Assisted Solution".

Please note that both are accepted solutions i just dont know why it is as it is. If someone could explain i would be most greatful.


Oddly enough, I am literally in the process of querying this. I will post that query in a few moments once I have completed it.

ampike I have a serious grievance.

I feel I provided an answer to your question however, you did not accept my code as your solution - you accepted dnilson's reply as the solution to your question.

I think it is unfair practice to ask a specific question and then not accept a solution which matches the criteria - especially when you accept another solution which does NOT match the criteria.

Please allow me to explain.

You stated you wanted a batch file - I provided this, dnilson did not. Allow me to remind you what you wrote:

   "...create a batch file..."

Furthermore, you gave an example of the required folder name. This was:

   "Report1.189 i will need my batch file to create a folder in C:\Reports called 2009189"

I met both these requirements, and more - dnilson did not.

(1) dnilson's code is NOT written in batch language
(2) dnilson's code does NOT create a folder nor move your files
(3) dnilson's code calculates the proper Julian date which is NOT what you asked for

(4) my code provides the pseudo-Julian date as specified in your question
(5) my code is written in batch language
(6) my code creates the required folder and moves your files as requested

Even though you asked for 'Julian' date, I was able to interpret that as a pseudo-Julian date based on the exmaple you gave, and this matches your requirements exactly.

While writing this comment, I note you have posted another comment in relation to this matter.

I kindly ask you to reconsider you decision not to accept my code as your solution. Please re-open this question and re-award points accordingly.

ampike, sorry, I forgot to add....

I am quite happy for points to be shared - it is the "Accepted"/"Assisted" status which is of concern to me



I can understand your concern. This is why i posted for someone to explain to me why this happened. This was in no way intentional.

I clicked on Accept mulitple responces as i didnt want to fall under the problem i had before with this accepting solutions and then i shared the points because both of you responded with solutions to my problem.

Also because of this Accepted / Assisted status i wrote another comment saying both are accepted solutions.

Honestly t0t0 i have no idea how it happened.

So what would you like me to do to resolve this?

Please contact a moderator by clicking on "Request Attention" (bottom right of question near small read icon)

Thank you.

PS I hope dnilson has no objection


t0t0 i have requested attension from the moderator as requested.

thank you


NOTE: I have every intention to refer this matter to an independent senior EE member.

I appreciate you are busy and not often able to analyse all responses and that is why my comment (ID: 24844537) is so detailed.

You state: "dnilson's comment was first"

This may be so however, his code DOES NOT return the date format as specified in the question.

As a moderator, you MUST be able to agree by examining the code that dnilson's program calculates the proper Julian value for a given date. This is done using a sequence of arithmentic operations. This is NOT what the asker requested.

The asker specifically requested the program should create folders in the following format: "2009189"

The only way, and proper way to arrive at the desired result is by slicing the date and putting the 'year' part to one side, then calculate the number of elapsed days in the year which is then re-appended to the year using string functions as I have done.

Not to mention the fact the asker requested this code to be written as a batch file. At no time ever did the asker indicate he wanted this to be written in VB code.

As a moderator, you MUST exercise fairness in your judgement. You have not done this. This is based on the fact you state dnilson's code was first without regard to who actually supplied the CORRECT solution.

The asker specifically requested a conversion from say,  'July 8th 2009' to '2009189'. As you can see, this comprises of two parts - the year part (2009) and a pseudo-Julian part (189). My code meets this requirement whereas, dnilson's code DOES NOT.

You will observe there is only a 25 minute time difference between dnilson posting his code and me posting my code. It could arguably be said the reason why why dnilson was able to post his code before I could post mine is because he did not supply his solution in the language specified by the asker nor did he include the other missing bits which were specified in the asker's question (create folders based on dates, and move files).

I am aware there is no advantage to be gained as far as points are concerned however, that is not the issue here. The issue is: I have laboured (freely) over this question and I expect proper recognition for the work I supply to EE.

As I satated above, I really do not mind splitting the points even though, I have every right  to object to that too and may choose to do so out of sheer awkwardness if this issue is not resolved as I am becoming increasingly tired of leaving it up to (although not in this case as I can see the asker had made a genuine mistake from his reply immediately afterwards) ignorant people who award points merely on a first-come basis or who judge code by their merits and who  often posess no experience whatsoever in programming.

You state "which I am loathe to do without a decent reason". I feel I have given you good reason however, if you fail to agree then I must insist this matter is looked at by an independent senior EE member.

Please refer to the asker's comment (ID: 24843843) and at the very least, due to a genuine error, allow the asker to re-submit which solution he prefers meets the required specifications

I await your reply.



Please reopen this questions so that i may proceed accordingly.

Let me know how to access it once its been open. I will keep checking back here for your answer.


You know, its summertime and some of us get a bit busy with everyone else out on vacation, and dont check back on closed questions.

So what happened here, I posted a reply to the question, which conformed to the authors question of "Does anyone have a better idea?

Points were awarded and the question closed.

So then t0t0 pitches a fit and if I'm reading this right the points were taken away and assigned to someone else.  Now I'd normally be inclined to simply let it go, let children be children and smile because author got a useful solution , but frankly the reply that toto (sic) wrote after his request for review was denied the first time is patenly offensive and fundementally wrong.

I mean, to say tha a .vbs solution is not a "batch file solution" all that is modern IT network administration.  I cannot believe I actuallly read those words.  That on top of what would have been a simple reordering of the substrings to get the format in the EXACT order specified.  I guess I would have re-written this simple change had the author not said "any ideas".  In any event, I notice that toto actually usedvbs himself in the answer so I guess talking outside bot sides of your mouth is an acceptable way to raise points.

I'm sorry ampike you deserved a more professional response than what you got, and I probably should have just ignored this but toto's tirade, and the the rather odd reactions and reverals of quomodo came o na day where we've been on generators for the last 6 hours in the summer heat, and well, I really dont think this was handled properly but I do hope you have your solution, and this behavior gets dealt with by the moderators.


Apologies for the late responce. I am ill and have not been back to the office but will give these a try.

Appreciate all of your responces.

Thank you for awarding me "Accepted" status. This was never about the points - my focus was that you accepted the solution which most closely matched the requirements as defined in your question.

Having said that, I am pleasantly surprised to find you have also awarded me FULL points (the grade 'A' being the cherry on the cake). This was never my intention (ref: ID: 24844686) however, in view of the solutions provided and after considerable afterthought, you have acted on fairness.

I am grateful for the considerable time you have given this matter.


What a sodding cheek! This is not about PLACATING me (ID: 24864662)- It's about receiving the CORRECT reward for providing the correct solution to the asker's question.

In the time it has taken me to respond to ampike for awarding my "ACCEPTED" status, I find you have taken this matter out of his hands completely and basically pleased yourself. This was both an uninvited and underhanded interference.

Furthermore, I find your following comment (ID: 24864662):

   "and you should not feel bullied into choosing one comment over another"

very distateful and unwarranted. At no time ever did I BULLY ampike into accepting my solution over anybody elses.

ampike requested attention from the moderators of his own free will. Oddly enough, it was you who suggested re-opening this question (ID: 24857750). ampike agreed to this of his own free will (ID: 24862522). You re-opened this question UNCONDITIONALLY (ID: 24863963). And without coercion, and of his own free will, ampike awarded points 'accordingly' - as he so put it (ID: 24862522).

When ampike first closed this question he stated (ID: 24845452) he accepted both mine and dnilson's solutions because we quote: "both responded with solutions" (ID: 24845452) however, it appears after some consideration, ampike had decided to award points based on the merit that my code embraced his requirements whereas, dnilson's code did not.

It is my contention you had a duty to check with ampike as to whether he did infact change his mind, and quite possibly why he did not award points to dnilson on this occasion, rather than just assuming he should have done - afterall, ampike didn't follow throught this time with an immmediate apology stating he had made an 'honest' mistake - as was the case previously (ID: 24845452).

It is an insult to ampike, myself, and I think dnilson must feel both insulted AND ashamed, that you should uninvitedly take this out of our hands and decide this issue above our heads. This is not moderating - this is overstepping your authority as well as a show of bias. Now who's placating who - as you so eloquently put it?

I note dnilson responded only when ampike had reconsidered awarding him any points. Where was he when I was fighting MY corner? While I was fighting my corner, I was as concerned that dnilson should continue to receive points for his efforts (ID: 24844686) even though strictly speaking he had no right to expect any. He failed to take that into consideration before whinging and stating: "so then t0t0 pitches a fit" (ID: 24864291).

dnilson then has the gall to state (ID: 24864291) "let children be children". Who's REALLY being the child here? Who's REALLY 'pitching a fit' - as dnilson puts it? I find his comments offensive and this is something you have not addressed.

As moderator, you have a DUTY TO ACT RESPONSIBLY and without personal bias. Furthermore, you have a duty to resolve issues which fall outside of the scope of ordinary experts, and it is in this premise that this matter was first referred to your attention.


You state (ID: 24857750): "At no stage was there any mention of incorrect points being awarded to you or dnilson". That never was the issue. ampike stated quite clearly (ID: 24843843) his intention was to accept BOTH of our codes equally as "ACCEPTED" status however, immediately after closing the question he realised he was unable to accept BOTH solutions with equal "ACCEPTED" status - despite the fact you state (ID: 24857750): "I see no error".

The question you should have asked yourself then is this: If ampike was aware of this before closing the question, would he have consciously chosen dnilson's code as the 'ACCEPTED' solution or would he have chosen mine?


However, you stated you are "loathed to do without a decent reason" (ID: 24857298).

Well, that WAS a 'decent' reason - but unfortunately you failed to acknowledge that.

I feel this could all have been avoided had you taken a little more time considering these facts istead of letting personal feelings could your judgement.

I will now refer this matter back to EE as this has caused me considerable stress.

This is NOT about "pitching a fit". This is about defending one's integrity, restoring respect and above all, fairness.


After reading ALL the comments and gaining a better understanding of the sequence of events, please allow me to state the following clearly for the record.

This customer alerted your attention asking you to "adjust" my "Assisted Solution" status to "Accepted Solution". The reason he gave is as follows: "As he is really the one that had the best solution" (Q_24570470).

Apart from the fact you failed to take this into consideration earlier, his request is NOT unreasonable and I see no reason why you had a problem with this.

My code WAS by far the better solution to ampike's question - that is an undisputable fact, so I see no reason why ampike should then state (Q_24862490): "This is my second question i have posted on EE where this guy (t0t0) is unhappy with something".

ampike clearly admits to having made a mistake (ID: 24843843) when he closed this question. He did this immediately afterwards and even BEFORE I raised this as an issue, so why shouldn't I be concerned that this matter be put right?

Furthermore, ampike states: "I really do not have the time to keep coming on here to explain myself each time this guy has a problem with the way he is rewarded points or not given the status he wants". In that case I STRONGLY URGE ampike to GIVE AS MUCH CONSIDERATION AND CARE when closing questions AS EXPERTS DO WHEN WRITING CODE TO SOLVE HIS PROBLEMS.

ampike then goes on to state the following: "My first experiance with him was with this question id:24547636".

Let me put the record straight here. In the incident ampike is referring to, he PUBLICLY stated my code DID NOT WORK (Q_24797223) and he accepted a solution from another EE member. After querying this with ampike, it so turned out HE HIMSELF HAD MADE AN ERROR, NOT ME, and that my code DID INFACT WORK CORRECTLY afterall (Q_24805719).

Was I wrong to query this? No! I have EVERY RIGHT TO EXPECT TO BE TREATED FAIRLY. Nevertheless, even though ampike openly apologised, I did not insist at that time that he re-open that question and make amends for HIS mistake. Infact, I never received any points whatsoever nor ACCEPTED or ASSISTED status - even though my correct code was posted BEFORE the code he accepted as the solution to his question.

Do you understand why I feel I had good cause to be concerned about this issue?

In my previous comment (ID: 24867807), I pointed out how you took this current issue out of our hands and decided dnilson should receive a share of the points without having been asked to do so, AND DESPITE YOU STATING TO ampike (Q_24866805): "when closing questions, remember that the points distribution is entirely up to you". Your actions certainly did not reinforce that advice.

Furthermore, your advice to ampike: "It should also be pointed out that you should not award points for effort only" and, "points are only awarded for *answers*, not effort". Therefore, I suspect it is for that reason that ampike decided NOT to award points to dnilson when closing this question the second time.

As I stated in my previous comment, you had a duty to check with ampike as to why he did not award points to dnilson before taking the matter into your own hands. Is that an unreasonable expectation? No!

More worryingly so, ampike goes on to make the follwing comments:

"And then i am threatned by him" (me) - I did no such thing. I merely stated as a matter of course that if he is unable to correct his own mistakes then I will refer the matter to a senior EE member (moderator). This is standard practice and there is nothing wrong in stating this him, just as you gave him the following advice (Q_24866805): "if you encounter any problems, click the Request Attention button straight away, and a moderator will deal with it".

I am also worried concerning the following statement made by ampike: "i am threatned by him saying he is going to report me to his EE senior member, which is most likely a friend of his". What on Earth ever gave ampike this impression? I cannot believe you did not inform him that just as much as he is able to request attention for help, so too can experts, and explain to him that there IS NO BIAS nor "FRIENDS OF HIS" as such, in these matters.

ampike refers to these incidences as "petty situations" (Q_24862490). I disagree. I have invested much of my own time FREELY as an EE expert and I deserve nothing more than to be treated FAIRLY - because that's the REAL issue here: FAIRNESS!

I am the victim here - the victim of ampike's mistakes (on TWO separate occasions) due to HIS incompetence, NOT MINE. Why should I just let it slip by? Perhaps this is a good lesson for ampike for the future. Hopefully, he will have learnt the importance of treating experts fairly and with equal consideration to how experts treat him as a customer of EE. I have done absolutely NOTHING wrong here. I have not been rude. I have not been unreasonable. I have not been threatening, and I certainly have not been childish. I have merely followed procedure.

ampike then goes on to state: "And if i ignore him or dont go back to my EE account for a few days he threatens to tell his buddy EE senior member on me". I kindly ask you to remove this ridiculous nonsense from EE altogehter as it is childish and silly!

Finally, and perhaps MOST WORRYINGLY of all is your immediate response to this silly nonsence. You state: "What you have done here is fine". Well, may I suggest you might have been a little too short-sighted here because ampike's delusions do not sound "fine" to me.

And perhaps the saddest thing in all is that it almost resulted in animosity between to experts - myself and dnilson. Fortunately, this was avoided (on my part) having gained a great understanding of where the real fault lay - and this is something YOU as a moerator should have spotted.

Nevertheless, I hope this comment puts the record straight that I am NOT the trouble-maker both ampike and dnilson makes out I am. And I fully sympathise with dnilson as one expert to another, and hope he is as sympathetic having gained a greater insight into this issue.

I will now head over to the previous question which ampike brought into focus and request attention that that too be put right.


Perhaps you may take the time to read my previous comment - especially where I write: "I fully sympathise with dnilson as one expert to another, and hope he is as sympathetic having gained a greater insight into this issue". The reasons are stated in my comment.

I have just realised none of the 'Q_' links work in my last two replies so I will post these again with updated links.
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a free trial preview!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.