bsharath
asked on
Need to find all the latest files that have been created in a folde i mention.
Hi,
Need to find all the latest files that have been created in a folde i mention.
Say i have a folder called C:\Tools. I Want a script which will search the folder for the created date i mention and list the names in a txt file.
Regards
Sharath
Need to find all the latest files that have been created in a folde i mention.
Say i have a folder called C:\Tools. I Want a script which will search the folder for the created date i mention and list the names in a txt file.
Regards
Sharath
Heres a macro
Sub a1()
Dim FSO As Object
Dim FileCreated As String
Dim FileName As String 'Includes the file path
Dim MyDate, FF as Integer
MyDate = #February 12, 1985# 'Set your Date here
Set FSO =CreateObject("Scripting.F ileSystemO bject")
Filename = Dir("C:\Tools")
FF=FreeFile
Open "C:\filename.txt" for output as #FF
Do
if FSO.GetFile(FileName).Date Created > MyDate then
Print #FF , FileName
End if
Filename = Dir$()
Loop Until Filename<>""
CloseFF
End Sub
Sub a1()
Dim FSO As Object
Dim FileCreated As String
Dim FileName As String 'Includes the file path
Dim MyDate, FF as Integer
MyDate = #February 12, 1985# 'Set your Date here
Set FSO =CreateObject("Scripting.F
Filename = Dir("C:\Tools")
FF=FreeFile
Open "C:\filename.txt" for output as #FF
Do
if FSO.GetFile(FileName).Date
Print #FF , FileName
End if
Filename = Dir$()
Loop Until Filename<>""
CloseFF
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Pass the parameters as follows:
filename (space) path to check in dos format(space) date to check for in short date format
filename.vbs folder date
filename.vbs c:\progra~1\microso~1 07/27/2007
zf
filename (space) path to check in dos format(space) date to check for in short date format
filename.vbs folder date
filename.vbs c:\progra~1\microso~1 07/27/2007
zf
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Any luck in testing this?
zf
zf
ASKER
Farhankazi.
Is there any thing i need to change in the script.?
Is there any thing i need to change in the script.?
No, nothing need to be changed.
Click Start -> Run -> Cmd.exe
Search.cmd C:\MyFiles 28/07/2007
Name of the batch file --- ^ ^---Folder name ^------------- Date
Click Start -> Run -> Cmd.exe
Search.cmd C:\MyFiles 28/07/2007
Name of the batch file --- ^ ^---Folder name ^------------- Date
ASKER
zoofan.
there is a file created in c:\filename but ithas no data in the file.
there is a file created in c:\filename but ithas no data in the file.
you did pass the parameters yes? as I ran this about 40 times the last on a folder that has well over 250,000 files and 40,000 subfolders(took a while too)
filename.vbs folder date
filename.vbs c:\progra~1\microso~1 07/27/2007
Leave off the leading zero in the date.
will retest
zf
filename.vbs folder date
filename.vbs c:\progra~1\microso~1 07/27/2007
Leave off the leading zero in the date.
will retest
zf
I have rerun this on 10 different folders all folders that the script is not located in and is working, but did find if you add the leading zero to the date 07 is returns an empty file failing all date tests.
and in its current directory passing a period as the folder to check
filename.vbs c:\ 7/29/2007
filename.vbs . 7/29/2007
and the output file is created in the same directory the script is located in.
zf
and in its current directory passing a period as the folder to check
filename.vbs c:\ 7/29/2007
filename.vbs . 7/29/2007
and the output file is created in the same directory the script is located in.
zf
Beware, that the script will fail if you run it on an open file as windows cant open the same file twice.
zf
zf
Oh and you need to have files in that folder that were actually created on the date you specify :-)
optionally you can modify the two
Date2 = FormatDateTime(objFile.Dat eCreated,2 )
lines to read
Date2 = FormatDateTime(objFile.Dat eLastModif ied,2)
And instead of creation date it will check modified date.
zf
optionally you can modify the two
Date2 = FormatDateTime(objFile.Dat
lines to read
Date2 = FormatDateTime(objFile.Dat
And instead of creation date it will check modified date.
zf
ASKER
Zoofan
i used this command
findcreateddate.vbs c:\ 07/29/2007
I created a folder and some file now in c drive.But the text file does not update any created dates.
Farhankazi
I used your script too but no data is being updated.
i used this command
findcreateddate.vbs c:\ 07/29/2007
I created a folder and some file now in c drive.But the text file does not update any created dates.
Farhankazi
I used your script too but no data is being updated.
bsharath leave the leading zero off the date
zf
zf
command
findcreateddate.vbs c:\ 7/29/2007
zf
findcreateddate.vbs c:\ 7/29/2007
zf
ASKER
After i changed th date to 7/29/2007 i got it working.Thanks.
What command did you applied?
Great, I was getting worried as Im still running it to test.
glad it is working,
zf
glad it is working,
zf
see the above link