Sign in to follow this  
Followers 0
jben

Loop to decide folder name

13 posts in this topic

#1 ·  Posted (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 by jben

Share this post


Link to post
Share on other sites



if january 1st,2nd,3rd,4th,5th,6th then = Week1

are 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

Share this post


Link to post
Share on other sites

name of folder..

so name of folder will = the week number determined by the loop

thanks

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

#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

Share this post


Link to post
Share on other sites

hey

with this code is it possible to add more dates to the loop..so i can check more than 1 month?...thanks

Share this post


Link to post
Share on other sites

#8 ·  Posted (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 by zorphnog

Share this post


Link to post
Share on other sites

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...

Share this post


Link to post
Share on other sites

#10 ·  Posted (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 by jben

Share this post


Link to post
Share on other sites

#11 ·  Posted (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 by jben

Share this post


Link to post
Share on other sites

#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

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0