MSFN Forum: Batch Help - MSFN Forum

Jump to content



Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Batch Help Any help would be great! Rate Topic: -----

#1 User is offline   hvyhttr 

  • Group: Members
  • Posts: 5
  • Joined: 11-January 08

Posted 11 January 2008 - 12:05 PM

Here is what I am trying to do. I know how to write the command, but I am not sure how to set up the variables. Can someone please help me?

E:
IF NOT EXIST E:\working\%YEAR%\ MKDIR E:\working\%YEAR%\
IF NOT EXIST E:\working\%YEAR%\%MONTH%\ MKDIR E:\working\%YEAR%\%MONTH%\

Any help would be great. Thank you.


#2 User is online   IcemanND 

  • MSFN Junkie
  • Group: Super Moderator
  • Posts: 3,239
  • Joined: 24-September 03
  • OS:Windows 7 x64
  • Country: Country Flag

Posted 11 January 2008 - 12:49 PM

what format do you want %year% and %month% to return?

#3 User is offline   hvyhttr 

  • Group: Members
  • Posts: 5
  • Joined: 11-January 08

Posted 11 January 2008 - 01:35 PM

YYYY for the Year
MM for the Month (01, 02, 03, etc)

#4 User is online   IcemanND 

  • MSFN Junkie
  • Group: Super Moderator
  • Posts: 3,239
  • Joined: 24-September 03
  • OS:Windows 7 x64
  • Country: Country Flag

Posted 11 January 2008 - 01:50 PM

%date:~-4% = year
%date:~4,2% = month
This will depend upon you default date format so you may need to adjust.

%date:~-4% returns just the last four characters of %date%
%date:~4,2% returns character 5 and 6

IF NOT EXIST E:\working\%date:~-4%\ MKDIR E:\working\%date:~-4%\
IF NOT EXIST E:\working\%date:~-4%\%date:~4,2%\ MKDIR E:\working\%date:~-4%\%date:~4,2%\


#5 User is offline   hvyhttr 

  • Group: Members
  • Posts: 5
  • Joined: 11-January 08

Posted 11 January 2008 - 01:55 PM

Thank you very much...it works like a charm!

#6 User is offline   hvyhttr 

  • Group: Members
  • Posts: 5
  • Joined: 11-January 08

Posted 14 January 2008 - 08:27 AM

ok, at 12:05 am each night, I move log files into the created folder above. On the first of each month (at 12:05 am) I will be moving the last log of the previous month, but it will create a folder for the new month and move it there. How I can keep this from happening or what work around can I implement? The current naming format of the logs is exYYMMDD.log. Again, any help would be greatly appreciated.

#7 User is online   jaclaz 

  • The Finder
  • Group: Developers
  • Posts: 8,792
  • Joined: 23-July 04
  • OS:none specified
  • Country: Country Flag

Posted 14 January 2008 - 11:04 AM

Not wanting to "prevent" you in any way from learning how to write a batch file, mind you :), but maybe if all you have to do is copying some log files at certain date/times, you could use a pre-made solution, something like this should be right for your needs:
http://www.xs4all.nl...rror/index.html

:unsure:

If you want to write your own batch file, you should have a look at this site:
http://www.robvanderwoude.com/

where you can find lots of examples and "tricks".

jaclaz

#8 User is offline   hvyhttr 

  • Group: Members
  • Posts: 5
  • Joined: 11-January 08

Posted 14 January 2008 - 11:23 AM

thank you very much!!

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users



All trademarks mentioned on this page are the property of their respective owners
Copyright © 2001 - 2011 msfn.org
Privacy Policy