topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Friday December 13, 2024, 9:03 am
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: NW IDEA: Drive to open on Dated folder  (Read 28338 times)

nogojoe

  • Charter Member
  • Joined in 2006
  • ***
  • Posts: 169
    • View Profile
    • Donate to Member
NW IDEA: Drive to open on Dated folder
« on: January 19, 2008, 04:32 PM »
Hi Coders

I have a partioned drive which I download programs, web pages, etc.to .  almost on a daily basis 
This is done mostly through a program downloader (called DOWNLOADER) it automatically archives the programs etc into a dated folder ie 20/01/ 2008.
I leave these in the folders there in which they are archived in until they are needed.

What I want to be able to is to open the today’s dated archived folder when I access the drive which there are on.

This hopefully would be be done from a shortcut from the desktop.
The coded program would have to locate the (today’s)dated folder if it exists and if a today's dated folder doesn’t exist open the drive as normal .
The date format is dd/mm/yyyy

Many thanks

nogojoe

Often the most convincing people are those who have lost the plot so much they don't recognize the difference between fact and fantasy

jgpaiva

  • Global Moderator
  • Joined in 2006
  • *****
  • Posts: 4,727
    • View Profile
    • Donate to Member
Re: NW IDEA: Drive to open on Dated folder
« Reply #1 on: January 19, 2008, 05:07 PM »
How about if today's folder isn't found, yesterday's folder is opened, or if that one isn't found either, the parent folder is opened?

jgpaiva

  • Global Moderator
  • Joined in 2006
  • *****
  • Posts: 4,727
    • View Profile
    • Donate to Member
Re: NW IDEA: Drive to open on Dated folder
« Reply #2 on: January 19, 2008, 05:38 PM »
Ok, done.

I attached to this post, both the source and the compiled version. (to run the source you need autohotkey)

To run it, just create a shortcut to it and pass it as argument the parent folder of the dated folders.
« Last Edit: January 20, 2008, 05:01 AM by jgpaiva »

nogojoe

  • Charter Member
  • Joined in 2006
  • ***
  • Posts: 169
    • View Profile
    • Donate to Member
Re: NW IDEA: Drive to open on Dated folder
« Reply #3 on: January 19, 2008, 05:41 PM »
That would be OK sounds a good idea especially around midnight it would come in handy.good thinking.

I am on WXP SP2.

My drive letter is “ I “ 

The folders are archived straight to drive I not under any archive folder for Downloader

Regards
nogojoe
Often the most convincing people are those who have lost the plot so much they don't recognize the difference between fact and fantasy

jgpaiva

  • Global Moderator
  • Joined in 2006
  • *****
  • Posts: 4,727
    • View Profile
    • Donate to Member
Re: NW IDEA: Drive to open on Dated folder
« Reply #4 on: January 19, 2008, 05:44 PM »
Ok, following your post, you should create a shortcut that has something like this on it's target:

OpenTodaysFolder.exe i:\

That would be OK sounds a good idea especially around midnight it would come in handy
Yep, that's exactly what i though.

PS: notice that i already posted the solution on my post above! ;)

nogojoe

  • Charter Member
  • Joined in 2006
  • ***
  • Posts: 169
    • View Profile
    • Donate to Member
Re: NW IDEA: Drive to open on Dated folder
« Reply #5 on: January 19, 2008, 07:36 PM »
Hi jgpaiva

Sorry I haven’t got back to you earlier
Downloaded the exe.
Put it in the I drive created a shortcut with no joy.
Tried your suggestion as argument came up with the following message

Error failed attempt to lauch program or document
action:<1>
param:<>

the current thread will exit

Specifically the system cannot find the file specified

Line#
 --- 037:run,%folder%

nogojoe

Thanks for being so quick with the coding from the beginning bear with me if I don’t respond immediately
Often the most convincing people are those who have lost the plot so much they don't recognize the difference between fact and fantasy

jgpaiva

  • Global Moderator
  • Joined in 2006
  • *****
  • Posts: 4,727
    • View Profile
    • Donate to Member
Re: NW IDEA: Drive to open on Dated folder
« Reply #6 on: January 20, 2008, 05:04 AM »
Oh, sorry. There was an error in the one i posted above. Should be corrected now. Just replace the older version and try again :)

nogojoe

  • Charter Member
  • Joined in 2006
  • ***
  • Posts: 169
    • View Profile
    • Donate to Member
Re: NW IDEA: Drive to open on Dated folder
« Reply #7 on: January 21, 2008, 05:40 PM »
Hi jgpaiva

Downloade the new version and ran it with no joy.

Created a shortcut from the exe for the desktop and ran it from there and got the message

Please pass the parent folder as the argument!
(Shortcut properties ----Target I:\OpenFolder\OpenTodaysFolder.exe  Start in I:\OpenFolder)

Edited shortcut properties to----TargetOpenTodaysFolder.exe i:\ Start in I:\OpenFolder

Now I get the I drive folder to open however after ensuing that today’s and yesterday’s (dated) folders were present closing the window and activating the shortcut I still only get the “I“ drive window to open

Regards nogojoe
Often the most convincing people are those who have lost the plot so much they don't recognize the difference between fact and fantasy

mhb

  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 22
  • There is no life before coffee!
    • View Profile
    • Donate to Member
Re: NW IDEA: Drive to open on Dated folder
« Reply #8 on: January 21, 2008, 06:10 PM »
Hi,

maybe the problem is raised by the '/'-sign.
My XP-system doesn't allow me to even create a directory containing the slash.

I would suggest that you try to substitute the slash with a minus or underscore.

Greeting,
Marc
There's nothing new under the sun,
but there are lots of old things we don't know. (Ambrose Bierce)

nogojoe

  • Charter Member
  • Joined in 2006
  • ***
  • Posts: 169
    • View Profile
    • Donate to Member
Re: NW IDEA: Drive to open on Dated folder
« Reply #9 on: January 21, 2008, 06:22 PM »
Hi Marc

Tried your suggestions  - + _

Came up with error message


Error failed attempt to lauch program or document
action:<1-> and <I_> respectively
param:<>

the current thread will exit

Specifically the system cannot find the file specified

Line#
 --- 037:run,%folder%

nogojoe


Often the most convincing people are those who have lost the plot so much they don't recognize the difference between fact and fantasy
« Last Edit: January 21, 2008, 06:24 PM by nogojoe »

mhb

  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 22
  • There is no life before coffee!
    • View Profile
    • Donate to Member
Re: NW IDEA: Drive to open on Dated folder
« Reply #10 on: January 21, 2008, 06:34 PM »
Hi nogojoe

I got bored tonight, so I just made the changes I suggested earlier.
Maybe you can try the attached files and see if this version is working also on your system.

Since I just changed the date divider from slash to minus you can call the .exe or the .ahk script as stated before.

Target :   C:\Tools\OpenTodayFolder.exe I:\
Start in:   C:\Tools

The directory containing your daily download should be named like: 22-01-2008 and should be located under I:\

Hope that helps,
Marc
There's nothing new under the sun,
but there are lots of old things we don't know. (Ambrose Bierce)
« Last Edit: January 21, 2008, 06:36 PM by mhb »

jgpaiva

  • Global Moderator
  • Joined in 2006
  • *****
  • Posts: 4,727
    • View Profile
    • Donate to Member
Re: NW IDEA: Drive to open on Dated folder
« Reply #11 on: January 21, 2008, 06:55 PM »
oh, mhb.. You're probably right.
That means there's something i misunderstood.

nogojoe: does the downloader create a series of nested folders, so that you have something like this:

2007/
   12/
      9
      10
      31
   11/
      1
      30
2008
   1/
      8
      21

nogojoe

  • Charter Member
  • Joined in 2006
  • ***
  • Posts: 169
    • View Profile
    • Donate to Member
Re: NW IDEA: Drive to open on Dated folder
« Reply #12 on: January 21, 2008, 07:07 PM »
Hi jgpaiva

No nested folders.

20-12-2007
21-12-2007
22-12-2007
20-01-2008
21-01-2008
22-01-2008
etc
just as if you create a new folder and name(in this case date it) as such

nogojoe
Often the most convincing people are those who have lost the plot so much they don't recognize the difference between fact and fantasy

jgpaiva

  • Global Moderator
  • Joined in 2006
  • *****
  • Posts: 4,727
    • View Profile
    • Donate to Member
Re: NW IDEA: Drive to open on Dated folder
« Reply #13 on: January 21, 2008, 07:10 PM »
Ok, then mhb's variation should work now :)

nogojoe

  • Charter Member
  • Joined in 2006
  • ***
  • Posts: 169
    • View Profile
    • Donate to Member
Re: NW IDEA: Drive to open on Dated folder
« Reply #14 on: January 21, 2008, 07:28 PM »
A thing of beauty and a joy for ever

Thanks jgpaiva and Marc

Working perfectly
Often the most convincing people are those who have lost the plot so much they don't recognize the difference between fact and fantasy

jgpaiva

  • Global Moderator
  • Joined in 2006
  • *****
  • Posts: 4,727
    • View Profile
    • Donate to Member
Re: NW IDEA: Drive to open on Dated folder
« Reply #15 on: January 22, 2008, 04:15 AM »
Great! Glad to know that, nogojoe :D

mhb

  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 22
  • There is no life before coffee!
    • View Profile
    • Donate to Member
Re: NW IDEA: Drive to open on Dated folder
« Reply #16 on: January 22, 2008, 08:11 AM »
Thanks, but its actully all jgpaive work.

jgpaiva: hope it was ok that I changed your code.

cheers,
Marc
There's nothing new under the sun,
but there are lots of old things we don't know. (Ambrose Bierce)

jgpaiva

  • Global Moderator
  • Joined in 2006
  • *****
  • Posts: 4,727
    • View Profile
    • Donate to Member
Re: NW IDEA: Drive to open on Dated folder
« Reply #17 on: January 22, 2008, 08:43 AM »
No problem, mhb :)

nogojoe

  • Charter Member
  • Joined in 2006
  • ***
  • Posts: 169
    • View Profile
    • Donate to Member
Re: NEW IDEA: Drive to open on Dated folder
« Reply #18 on: January 26, 2008, 06:51 PM »
Hi ,

“jgpaiva“ has coded this small program to suit a download manger program called Star Downloader (free)

http://www.stardownloader.com/

nogojoe

Works brilliantly.thanks again jgpaiva  :Thmbsup:


Coded program in lower posting

Often the most convincing people are those who have lost the plot so much they don't recognize the difference between fact and fantasy
« Last Edit: January 27, 2008, 01:18 AM by nogojoe »

jgpaiva

  • Global Moderator
  • Joined in 2006
  • *****
  • Posts: 4,727
    • View Profile
    • Donate to Member
Re: NW IDEA: Drive to open on Dated folder
« Reply #19 on: January 27, 2008, 08:23 AM »
Through PM, nogojoe asked for a modification of this program to open the most recent dated folder, so, here it is.
Notice that it doesn't stop looking, so, if you don't have any folder that matches the dd-MM-yyyy format, it will go into an infinite loop.

[edit] fixed error [/edit]
« Last Edit: January 27, 2008, 03:33 PM by jgpaiva »

jgpaiva

  • Global Moderator
  • Joined in 2006
  • *****
  • Posts: 4,727
    • View Profile
    • Donate to Member
Re: NW IDEA: Drive to open on Dated folder
« Reply #20 on: January 27, 2008, 03:34 PM »
Oops...  Made a small mistake. (i swear i'll test stuff the next time :P)
Please redownload the next.

nogojoe

  • Charter Member
  • Joined in 2006
  • ***
  • Posts: 169
    • View Profile
    • Donate to Member
Re: NW IDEA: Drive to open on Dated folder
« Reply #21 on: January 27, 2008, 04:38 PM »
Thanks jgpaiva

Both programs going to order 

Brilliant

nogojoe
Often the most convincing people are those who have lost the plot so much they don't recognize the difference between fact and fantasy

vixay

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 140
  • ViXaY
    • View Profile
    • Donate to Member
Re: NW IDEA: Drive to open on Dated folder
« Reply #22 on: September 17, 2008, 03:52 AM »
Here's a script I've been using for myself to open/create(if it doesn't exist) a dated folder in a particular directory (called Open Today.vbs :))
It's long because I had to add Date formatting functions to it. I am just posting it here as an alternative for the other inquiring minds. The AHK solution is so much simpler :), but this might be useful when you need it in a pinch. This could easily be customized to accept arguments as well.

Save as Open Today.vbs
Code: Visual Basic [Select]
  1. Dim sNow, strDateTime, sPath, sFinalPath
  2. 'sPath = "PUT YOUR FOLDER NAME BELOW"
  3. sPath = "C:\YourFolder"
  4.  
  5. 'TESTING CODE
  6. sNow = Replace(Replace(Now(),"/","-"),":",".")
  7. sNow = Year(Date) & Month(Date) & Day(Date)'& MonthName(Date)
  8. 'Wscript.Echo sNow
  9. 'Wscript.echo FormateDateTime(Date(),vblongdate)
  10. 'END TESTING CODE
  11.  
  12. 'Generate Full PathName
  13. 'strDateTime = formatDate("%g:%i%a, %l %j%O %F, %Y", UDate(Now()))
  14. strDateTime = formatDate("%Y-%m %M\%Y-%m-%d\", Now())
  15. sNow = formatDate("%Y-%m %M\", Now())
  16. 'Wscript.echo strDateTime
  17. sFinalPath = sPath & strDateTime
  18.  
  19. 'Create the folder if it doesn't exist
  20. On Error Resume Next
  21. Dim fso
  22. Set fso = CreateObject("Scripting.FileSystemObject")
  23. If Not fso.FolderExists(sFinalPath) Then
  24. 'Check Subfolder level and create those first?
  25.         If Not fso.FolderExists(sPath & sNow) Then fso.CreateFolder(sPath & sNow)
  26.         Wscript.echo "Creating: " & sFinalPath
  27.         fso.CreateFolder(sFinalPath)
  28. End If
  29. If (Err.Number <> 0) Then
  30.         Wscript.Echo "Error creating folder! " & Err.Number & " :" & Err.Description
  31.         Err.Clear
  32.         On Error GoTo 0
  33.         Wscript.Quit
  34. Else
  35. End If
  36. On Error GoTo 0
  37.  
  38. 'Open the folder
  39. Dim shAppObj
  40. If MsgBox( "Open Folder?" & vbcrlf & sFinalPath, vbYesNo + vbQuestion, "Create\Open Folder?") = vbYes Then
  41.         Set shAppObj = nothing
  42.         Set shAppObj = CreateObject("WScript.Shell")
  43.         shAppObj.Run "explorer " & sFinalPath
  44. End If
  45. Set shAppObj = nothing
  46. Wscript.Quit   
  47.  
  48. 'Recursively create parent folders if they do not exist
  49. 'Sub CreateMissingFolders(strPath)
  50. 'Dim fso, sParent
  51. 'Set fso = CreateObject("Scripting.FileSystemObject")
  52. 'If Not fso.FolderExists(strPath) Then
  53. 'Check Subfolder level and create those first?
  54. '       sParent = Mid(1,
  55. '       CreateMissingFolder()
  56. '       Wscript.echo sFinalPath
  57. '       fso.CreateFolder(strPath)
  58. 'End If
  59. 'End sub
  60.  
  61. Function unUDate(intTimeStamp)
  62. unUDate = DateAdd("s", intTimeStamp, "01/01/1970 00:00:00")
  63. end Function
  64.  
  65. Function UDate(oldDate)
  66. UDate = DateDiff("s", "01/01/1970 00:00:00", oldDate)
  67. end Function
  68.  
  69. Function formatDate(format, intTimeStamp)
  70. Dim monthname()
  71. Redim monthname(12)
  72. monthname(1) = "January"
  73. monthname(2) = "February"
  74. monthname(3) = "March"
  75. monthname(4) = "April"
  76. monthname(5) = "May"
  77. monthname(6) = "June"
  78. monthname(7) = "July"
  79. monthname(8) = "August"
  80. monthname(9) = "September"
  81. monthname(10) = "October"
  82. monthname(11) = "November"
  83. monthname(12) = "December"
  84.  
  85. dim unUDate, A
  86.  
  87. dim OriginalLocale
  88. dim res
  89. OriginalLocale = GetLocale
  90. res = SetLocale("en-gb")
  91.  
  92. ' Test to see if intTimeStamp looks valid. If not, they have passed a normal date
  93. if not (isnumeric(intTimeStamp)) then
  94. if isdate(intTimeStamp) then
  95. intTimeStamp = DateDiff("S", "01/01/1970 00:00:00", intTimeStamp)
  96. else
  97. response.write "Date Invalid"
  98. exit function
  99. end if
  100. end if
  101.  
  102. if (intTimeStamp=0) then
  103. unUDate = now()
  104. else
  105. unUDate = DateAdd("s", intTimeStamp, "01/01/1970 00:00:00")
  106. end if
  107.  
  108. unUDate = trim(unUDate)
  109.  
  110. 'bug fix for midnight problems
  111. If (Len(unUDate) <= 11) Then unUDate = Trim(unUDate) & " 00:00:00"
  112.  
  113. dim startM : startM = 1
  114. dim startD : startD = InStr(startM, unUDate, "/")+1
  115. dim startY : startY = InStr(startD, unUDate, "/")+1
  116. dim startHour : startHour = InStr(startY, unUDate, " ")+1
  117. dim startMin : startMin = InStr(startHour, unUDate, ":")+1
  118. dim startSec : startSec = InStr(startMin+1, unUDate, ":")+1
  119. dim dateMonth : dateMonth = mid(unUDate, startD, ((startY - 1) - startD))
  120. dim dateDay : dateDay = mid(unUDate, 1, ((startD - 1) - 1))
  121. dim dateYear : dateYear = Year(unUDate)
  122. dim dateHour : dateHour = mid(unUDate, startHour, ((startMin - startHour) - 1))
  123. dim dateMinute : dateMinute = mid(unUDate, startMin, 2)
  124. dim dateSecond : dateSecond = mid(unUDate, InStr(startMin, unUDate, ":") + 1, 2)
  125.  
  126. format = replace(format, "%Y", right(dateYear, 4))
  127. format = replace(format, "%y", right(dateYear, 2))
  128. format = replace(format, "%m", dateMonth)
  129. format = replace(format, "%n", cint(dateMonth))
  130.  
  131. ' Response.Write CStr(cint(dateMonth))
  132. ' Response.Flush
  133.  
  134. format = replace(format, "%F", monthname(cint(dateMonth)))
  135. format = replace(format, "%M", left(monthname(cint(dateMonth)), 3))
  136. format = replace(format, "%d", dateDay)
  137. format = replace(format, "%j", cint(dateDay))
  138. format = replace(format, "%h", mid(unUDate, startHour, 2))
  139. format = replace(format, "%g", cint(mid(unUDate, startHour, 2)))
  140.  
  141. if (cint(dateHour) > 12) then
  142. A = "PM"
  143. else
  144. A = "AM"
  145. end if
  146. format = replace(format, "%A", A)
  147. format = replace(format, "%a", lcase(A))
  148.  
  149. if (A = "PM") then format = replace(format, "%H", Right("00" & dateHour - 12, 2))
  150. format = replace(format, "%H", dateHour)
  151. if (A = "PM") then format = replace(format, "%G", left("0" & cint(dateHour) - 12, 2))
  152. format = replace(format, "%G", cint(dateHour))
  153.  
  154. format = replace(format, "%i", dateMinute)
  155. format = replace(format, "%I", cint(dateMinute))
  156. format = replace(format, "%s", dateSecond)
  157. format = replace(format, "%S", cint(dateSecond))
  158. format = replace(format, "%L", WeekDay(unUDate))
  159. format = replace(format, "%D", left(WeekDayName(WeekDay(unUDate)), 3))
  160. format = replace(format, "%l", WeekDayName(WeekDay(unUDate)))
  161. format = replace(format, "%U", intTimeStamp)
  162. format = replace(format, "11%O", "11th")
  163. format = replace(format, "1%O", "1st")
  164. format = replace(format, "12%O", "12th")
  165. format = replace(format, "2%O", "2nd")
  166. format = replace(format, "13%O", "13th")
  167. format = replace(format, "3%O", "3rd")
  168. format = replace(format, "%O", "th")
  169.  
  170. formatDate = format
  171. res = SetLocale(OriginalLocale)
  172.  
  173. End Function


Edit: Fixed typo
"Drunk on the Nectar of Life!" -me