DonationCoder.com forum
 
Read-only archive. This is a static copy of the DonationCoder.com forum. Reading and searching work as before; logging in, posting and private messages do not.
Archive of 2026-10-21 · About this archive · Main site

Author Topic: NW IDEA: Drive to open on Dated folder  (Read 32,331 times)

nogojoe

  • Charter Member
  • Joined in 2006
  • ***
  • Posts: 174
NW IDEA: Drive to open on Dated folder
« on: January 19, 2008, 10: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

  • Artificial Idiocy
  • Global Moderator
  • Joined in 2006
  • *****
  • Posts: 4,727
    • Cody Award
    • Participated in NANY Challenge Once
    • Coding Snacks
    • Portugal Inhabitant
    • Linux User
Re: NW IDEA: Drive to open on Dated folder
« Reply #1 on: January 19, 2008, 11: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

  • Artificial Idiocy
  • Global Moderator
  • Joined in 2006
  • *****
  • Posts: 4,727
    • Cody Award
    • Participated in NANY Challenge Once
    • Coding Snacks
    • Portugal Inhabitant
    • Linux User
Re: NW IDEA: Drive to open on Dated folder
« Reply #2 on: January 19, 2008, 11: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, 11:01 AM by jgpaiva »

nogojoe

  • Charter Member
  • Joined in 2006
  • ***
  • Posts: 174
Re: NW IDEA: Drive to open on Dated folder
« Reply #3 on: January 19, 2008, 11: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

  • Artificial Idiocy
  • Global Moderator
  • Joined in 2006
  • *****
  • Posts: 4,727
    • Cody Award
    • Participated in NANY Challenge Once
    • Coding Snacks
    • Portugal Inhabitant
    • Linux User
Re: NW IDEA: Drive to open on Dated folder
« Reply #4 on: January 19, 2008, 11:44 PM »
Ok, following your post, you should create a shortcut that has something like this on it's target:

Code
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: 174
Re: NW IDEA: Drive to open on Dated folder
« Reply #5 on: January 20, 2008, 01:36 AM »
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

  • Artificial Idiocy
  • Global Moderator
  • Joined in 2006
  • *****
  • Posts: 4,727
    • Cody Award
    • Participated in NANY Challenge Once
    • Coding Snacks
    • Portugal Inhabitant
    • Linux User
Re: NW IDEA: Drive to open on Dated folder
« Reply #6 on: January 20, 2008, 11: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: 174
Re: NW IDEA: Drive to open on Dated folder
« Reply #7 on: January 21, 2008, 11: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

  • There is no life before coffee!
  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 22
Re: NW IDEA: Drive to open on Dated folder
« Reply #8 on: January 22, 2008, 12:10 AM »
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: 174
Re: NW IDEA: Drive to open on Dated folder
« Reply #9 on: January 22, 2008, 12:22 AM »
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 22, 2008, 12:24 AM by nogojoe »

mhb

  • There is no life before coffee!
  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 22
Re: NW IDEA: Drive to open on Dated folder
« Reply #10 on: January 22, 2008, 12:34 AM »
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.

Code
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 22, 2008, 12:36 AM by mhb »

jgpaiva

  • Artificial Idiocy
  • Global Moderator
  • Joined in 2006
  • *****
  • Posts: 4,727
    • Cody Award
    • Participated in NANY Challenge Once
    • Coding Snacks
    • Portugal Inhabitant
    • Linux User
Re: NW IDEA: Drive to open on Dated folder
« Reply #11 on: January 22, 2008, 12:55 AM »
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: 174
Re: NW IDEA: Drive to open on Dated folder
« Reply #12 on: January 22, 2008, 01:07 AM »
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

  • Artificial Idiocy
  • Global Moderator
  • Joined in 2006
  • *****
  • Posts: 4,727
    • Cody Award
    • Participated in NANY Challenge Once
    • Coding Snacks
    • Portugal Inhabitant
    • Linux User
Re: NW IDEA: Drive to open on Dated folder
« Reply #13 on: January 22, 2008, 01:10 AM »
Ok, then mhb's variation should work now :)

nogojoe

  • Charter Member
  • Joined in 2006
  • ***
  • Posts: 174
Re: NW IDEA: Drive to open on Dated folder
« Reply #14 on: January 22, 2008, 01:28 AM »
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

  • Artificial Idiocy
  • Global Moderator
  • Joined in 2006
  • *****
  • Posts: 4,727
    • Cody Award
    • Participated in NANY Challenge Once
    • Coding Snacks
    • Portugal Inhabitant
    • Linux User
Re: NW IDEA: Drive to open on Dated folder
« Reply #15 on: January 22, 2008, 10:15 AM »
Great! Glad to know that, nogojoe :D

mhb

  • There is no life before coffee!
  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 22
Re: NW IDEA: Drive to open on Dated folder
« Reply #16 on: January 22, 2008, 02:11 PM »
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

  • Artificial Idiocy
  • Global Moderator
  • Joined in 2006
  • *****
  • Posts: 4,727
    • Cody Award
    • Participated in NANY Challenge Once
    • Coding Snacks
    • Portugal Inhabitant
    • Linux User
Re: NW IDEA: Drive to open on Dated folder
« Reply #17 on: January 22, 2008, 02:43 PM »
No problem, mhb :)

nogojoe

  • Charter Member
  • Joined in 2006
  • ***
  • Posts: 174
Re: NEW IDEA: Drive to open on Dated folder
« Reply #18 on: January 27, 2008, 12:51 AM »
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, 07:18 AM by nogojoe »

jgpaiva

  • Artificial Idiocy
  • Global Moderator
  • Joined in 2006
  • *****
  • Posts: 4,727
    • Cody Award
    • Participated in NANY Challenge Once
    • Coding Snacks
    • Portugal Inhabitant
    • Linux User
Re: NW IDEA: Drive to open on Dated folder
« Reply #19 on: January 27, 2008, 02:23 PM »
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, 09:33 PM by jgpaiva »

jgpaiva

  • Artificial Idiocy
  • Global Moderator
  • Joined in 2006
  • *****
  • Posts: 4,727
    • Cody Award
    • Participated in NANY Challenge Once
    • Coding Snacks
    • Portugal Inhabitant
    • Linux User
Re: NW IDEA: Drive to open on Dated folder
« Reply #20 on: January 27, 2008, 09: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: 174
Re: NW IDEA: Drive to open on Dated folder
« Reply #21 on: January 27, 2008, 10: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

  • ViXaY
  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 140
    • Coding Snacks
Re: NW IDEA: Drive to open on Dated folder
« Reply #22 on: September 17, 2008, 08: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: (vb)
Dim sNow, strDateTime, sPath, sFinalPath
'sPath = "PUT YOUR FOLDER NAME BELOW"
sPath = "C:\YourFolder"

'TESTING CODE
sNow = Replace(Replace(Now(),"/","-"),":",".")
sNow = Year(Date) & Month(Date) & Day(Date)'& MonthName(Date) 
'Wscript.Echo sNow
'Wscript.echo FormateDateTime(Date(),vblongdate)
'END TESTING CODE

'Generate Full PathName
'strDateTime = formatDate("%g:%i%a, %l %j%O %F, %Y", UDate(Now()))
strDateTime = formatDate("%Y-%m %M\%Y-%m-%d\", Now())
sNow = formatDate("%Y-%m %M\", Now())
'Wscript.echo strDateTime
sFinalPath = sPath & strDateTime

'Create the folder if it doesn't exist
On Error Resume Next
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
If Not fso.FolderExists(sFinalPath) Then
'Check Subfolder level and create those first?
	If Not fso.FolderExists(sPath & sNow) Then fso.CreateFolder(sPath & sNow)
	Wscript.echo "Creating: " & sFinalPath
	fso.CreateFolder(sFinalPath)
End If
If (Err.Number <> 0) Then
	Wscript.Echo "Error creating folder! " & Err.Number & " :" & Err.Description
	Err.Clear
	On Error GoTo 0
	Wscript.Quit
Else
End If
On Error GoTo 0

'Open the folder
Dim shAppObj
If MsgBox( "Open Folder?" & vbcrlf & sFinalPath, vbYesNo + vbQuestion, "Create\Open Folder?") = vbYes Then
	Set shAppObj = nothing
	Set shAppObj = CreateObject("WScript.Shell")
	shAppObj.Run "explorer " & sFinalPath
End If
Set shAppObj = nothing
Wscript.Quit	

'Recursively create parent folders if they do not exist
'Sub CreateMissingFolders(strPath)
'Dim fso, sParent
'Set fso = CreateObject("Scripting.FileSystemObject")
'If Not fso.FolderExists(strPath) Then
'Check Subfolder level and create those first?
'	sParent = Mid(1,
'	CreateMissingFolder()
'	Wscript.echo sFinalPath
'	fso.CreateFolder(strPath)
'End If	
'End sub

Function unUDate(intTimeStamp)
unUDate = DateAdd("s", intTimeStamp, "01/01/1970 00:00:00")
end Function

Function UDate(oldDate)
UDate = DateDiff("s", "01/01/1970 00:00:00", oldDate)
end Function

Function formatDate(format, intTimeStamp)
Dim monthname()
Redim monthname(12)
monthname(1) = "January"
monthname(2) = "February"
monthname(3) = "March"
monthname(4) = "April"
monthname(5) = "May"
monthname(6) = "June"
monthname(7) = "July"
monthname(8) = "August"
monthname(9) = "September"
monthname(10) = "October"
monthname(11) = "November"
monthname(12) = "December"

dim unUDate, A

dim OriginalLocale
dim res
OriginalLocale = GetLocale
res = SetLocale("en-gb")

' Test to see if intTimeStamp looks valid. If not, they have passed a normal date
if not (isnumeric(intTimeStamp)) then
if isdate(intTimeStamp) then
intTimeStamp = DateDiff("S", "01/01/1970 00:00:00", intTimeStamp)
else
response.write "Date Invalid"
exit function
end if
end if

if (intTimeStamp=0) then
unUDate = now()
else
unUDate = DateAdd("s", intTimeStamp, "01/01/1970 00:00:00")
end if

unUDate = trim(unUDate)

'bug fix for midnight problems
If (Len(unUDate) <= 11) Then unUDate = Trim(unUDate) & " 00:00:00"

dim startM : startM = 1
dim startD : startD = InStr(startM, unUDate, "/")+1
dim startY : startY = InStr(startD, unUDate, "/")+1
dim startHour : startHour = InStr(startY, unUDate, " ")+1
dim startMin : startMin = InStr(startHour, unUDate, ":")+1
dim startSec : startSec = InStr(startMin+1, unUDate, ":")+1
dim dateMonth : dateMonth = mid(unUDate, startD, ((startY - 1) - startD))
dim dateDay : dateDay = mid(unUDate, 1, ((startD - 1) - 1))
dim dateYear : dateYear = Year(unUDate)
dim dateHour : dateHour = mid(unUDate, startHour, ((startMin - startHour) - 1))
dim dateMinute : dateMinute = mid(unUDate, startMin, 2)
dim dateSecond : dateSecond = mid(unUDate, InStr(startMin, unUDate, ":") + 1, 2)

format = replace(format, "%Y", right(dateYear, 4))
format = replace(format, "%y", right(dateYear, 2))
format = replace(format, "%m", dateMonth)
format = replace(format, "%n", cint(dateMonth))

' Response.Write CStr(cint(dateMonth))
' Response.Flush

format = replace(format, "%F", monthname(cint(dateMonth)))
format = replace(format, "%M", left(monthname(cint(dateMonth)), 3))
format = replace(format, "%d", dateDay)
format = replace(format, "%j", cint(dateDay))
format = replace(format, "%h", mid(unUDate, startHour, 2))
format = replace(format, "%g", cint(mid(unUDate, startHour, 2)))

if (cint(dateHour) > 12) then
A = "PM"
else
A = "AM"
end if
format = replace(format, "%A", A)
format = replace(format, "%a", lcase(A))

if (A = "PM") then format = replace(format, "%H", Right("00" & dateHour - 12, 2))
format = replace(format, "%H", dateHour)
if (A = "PM") then format = replace(format, "%G", left("0" & cint(dateHour) - 12, 2))
format = replace(format, "%G", cint(dateHour))

format = replace(format, "%i", dateMinute)
format = replace(format, "%I", cint(dateMinute))
format = replace(format, "%s", dateSecond)
format = replace(format, "%S", cint(dateSecond))
format = replace(format, "%L", WeekDay(unUDate))
format = replace(format, "%D", left(WeekDayName(WeekDay(unUDate)), 3))
format = replace(format, "%l", WeekDayName(WeekDay(unUDate)))
format = replace(format, "%U", intTimeStamp)
format = replace(format, "11%O", "11th")
format = replace(format, "1%O", "1st")
format = replace(format, "12%O", "12th")
format = replace(format, "2%O", "2nd")
format = replace(format, "13%O", "13th")
format = replace(format, "3%O", "3rd")
format = replace(format, "%O", "th")

formatDate = format
res = SetLocale(OriginalLocale)

End Function


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

Original address: https://www.donationcoder.com/forum/index.php?topic=11925.0