jben Posted April 21, 2008 Share Posted April 21, 2008 (edited) Hey everyone. I'm just wondering, is it possible to create a loop to determine a folder name something like this: $foldername = loop if january 1st,2nd,3rd,4th,5th,6th then = Week1 if january 7th,8th,9th,10th,11th then = week 2 c:\output\$foldername <--the folder name is determined by the loop above.For example, if its January 1st then the folder name will be c:\output\Week 1 thanks Edited April 21, 2008 by jben Link to comment Share on other sites More sharing options...
d4rk Posted April 21, 2008 Share Posted April 21, 2008 if january 1st,2nd,3rd,4th,5th,6th then = Week1are you menting about the date of file or just the name of folder ? [quote]Don't expect for a perfect life ... Expect a least troubles ones[/quote]Contact me : ass@kiss.toWhat I Have Done :Favorites Manager Mangage your favorite's folder, that's coolPC Waker For those who want to save stickersWebScipts Supporter For those who've just started with Web and WebScriptsTemporary Looker Simple but powerful to manage your Temporary folder, you know what you downloaded[UDF] _NumberFormat() Better performance on number display[UDF] _DirGet() What a folder contain [how many (hidden,normal,...) files], with one line of code[UDF] _IsPressEs() Just like _IsPress() but for a group of keys Link to comment Share on other sites More sharing options...
jben Posted April 21, 2008 Author Share Posted April 21, 2008 name of folder.. so name of folder will = the week number determined by the loop thanks Link to comment Share on other sites More sharing options...
monoceres Posted April 21, 2008 Share Posted April 21, 2008 #include <date.au3> Dim $date[3]=[2008,04,21] DirCreate("Week "&_WeekNumberISO($date[0],$date[1],$date[2])) Broken link? PM me and I'll send you the file! Link to comment Share on other sites More sharing options...
jben Posted April 21, 2008 Author Share Posted April 21, 2008 brilliant bit of code. Is it possible to incorporate the year into the code as the "Week" bit... So "Week" can be year....Then I would have 200817 for instance Link to comment Share on other sites More sharing options...
d4rk Posted April 21, 2008 Share Posted April 21, 2008 #include <date.au3> Dim $date[3]=[2008,04,21] DirCreate(@YEAR & _WeekNumberISO($date[0],$date[1],$date[2])) [quote]Don't expect for a perfect life ... Expect a least troubles ones[/quote]Contact me : ass@kiss.toWhat I Have Done :Favorites Manager Mangage your favorite's folder, that's coolPC Waker For those who want to save stickersWebScipts Supporter For those who've just started with Web and WebScriptsTemporary Looker Simple but powerful to manage your Temporary folder, you know what you downloaded[UDF] _NumberFormat() Better performance on number display[UDF] _DirGet() What a folder contain [how many (hidden,normal,...) files], with one line of code[UDF] _IsPressEs() Just like _IsPress() but for a group of keys Link to comment Share on other sites More sharing options...
jben Posted April 21, 2008 Author Share Posted April 21, 2008 hey with this code is it possible to add more dates to the loop..so i can check more than 1 month?...thanks Link to comment Share on other sites More sharing options...
zorphnog Posted April 21, 2008 Share Posted April 21, 2008 (edited) If you want the actual week of the month you could use this. And create the directory as Year\Month\Week #, for instance 2008\April\Week 4. #include <Date.au3> DirCreate(@YEAR & "\" & @MON & "\" & "Week " & _GetWeekOfMonth()) Func _GetWeekOfMonth($iYear = @YEAR, $iMonth = @MON, $iDay = @MDAY) Local $iDayOffset = _DateToDayOfWeek($iYear, $iMonth, 1) - 1 If Mod(($iDay + $iDayOffset),7) = 0 Then Return Int(($iDay + $iDayOffset)/7) Else Return Int((($iDay + $iDayOffset)/7)+1) EndIf EndFunc Edited April 21, 2008 by zorphnog Link to comment Share on other sites More sharing options...
jben Posted April 21, 2008 Author Share Posted April 21, 2008 I'm trying to obtain the week number...So for instance we are in week 17 now...But I found that if I change the date and time properties on my PC it still states the number 17... Link to comment Share on other sites More sharing options...
jben Posted April 21, 2008 Author Share Posted April 21, 2008 (edited) Fixed it now...I just used this: #include <date.au3> Dim $date[3]=[@YEAR,@MON,@MDAY] DirCreate(@YEAR & _WeekNumberISO($date[0],$date[1],$date[2])) Thanks everyone for the help Edited April 21, 2008 by jben Link to comment Share on other sites More sharing options...
jben Posted April 21, 2008 Author Share Posted April 21, 2008 (edited) Hey. I've made an improvement to my code. The only problem I have is the "Somerset" bit is not working What i'm trying to achieve is move the contents of the c:\OUTPUT\MASTER folder to C:\OUTPUT\YEARWEEKNUMBER\Somerset which in this case would be moving the contents of MASTER folder to C:\OUTPUT\200817\Somerset. Anyone have any ideas?...thanks #include <date.au3> Dim $date[3]=[@YEAR,@MON,@MDAY] DirMove ("C:\OUTPUT\MASTER","C:\OUTPUT\" & @YEAR &_WeekNumberISO($date[0],$date[1],$date[2]"\Somerset")) Edited April 21, 2008 by jben Link to comment Share on other sites More sharing options...
zorphnog Posted April 21, 2008 Share Posted April 21, 2008 #include <date.au3> Dim $date[3]=[@YEAR,@MON,@MDAY] DirMove ("C:\OUTPUT\MASTER","C:\OUTPUT\" & @YEAR &_WeekNumberISO($date[0],$date[1],$date[2]) & "\Somerset")[/code]oÝ÷ Ø l¢'ò¢íýæ¥Á¬¬ºÈ§Ø^rêëz{]jײ¢çhmçkMúu«^jºÚÉ«¢+Ø¥¹±Õ±ÐíѹÔÌÐì)¥É5½Ù ÅÕ½ÐíèÀäÈí=UQAUPÀäÈí5MQHÅÕ½Ðì°ÅÕ½ÐíèÀäÈí=UQAUPÀäÈìÅÕ½ÐìµÀìeHµÀí}]9ÕµÉ%M Link to comment Share on other sites More sharing options...
zorphnog Posted April 21, 2008 Share Posted April 21, 2008 Hmm...for some reason i couldn't edit the last post. You may also need to make sure the directory exists before you try to move it. #include <date.au3> Local $sOutDir = "C:\OUTPUT\" & @YEAR & _WeekNumberISO() & "\Somerset" If Not FileExists($sOutDir) Then DirCreate($sOutDir) DirMove ("C:\OUTPUT\MASTER", $sOutDir) Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now