Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 7
Default File path listing and analysis

Hi

I have two main folders with many sub-folders and files, one has to be
combined into the other ensuring that the most up to date file is adopted
whenever appropriate. In order to do this I thought the best way would be to
down load or transfer complete filepaths and certain file properties (last
updated date) into Excel and analyse accordingly.

The structure of the two main folders differ.

Does anyone know how to transfer filepath lists and file properties to Excel?

I have looked at other posting son this subject and they seem to fall short
with the filepath and file properties requirements.

Any advice much appreciated
Dave
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 10,593
Default File path listing and analysis

Have you looked at using FileSystemObject to get those properties

Sub LoopFolders()
Dim oFSO
Dim Folder As Object
Dim Files As Object
Dim file As Object

Set oFSO = CreateObject("Scripting.FileSystemObject")

Set Folder = oFSO.GetFolder("C:\Folder1")

For Each file In Folder.Files
Debug.Print file.Path
Debug.Print file.DatelastModified
Next file

Set file = Nothing
Set Folder = Nothing
Set oFSO = Nothing
End Sub

--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my addy)



"DaveyC" wrote in message
...
Hi

I have two main folders with many sub-folders and files, one has to be
combined into the other ensuring that the most up to date file is adopted
whenever appropriate. In order to do this I thought the best way would be
to
down load or transfer complete filepaths and certain file properties (last
updated date) into Excel and analyse accordingly.

The structure of the two main folders differ.

Does anyone know how to transfer filepath lists and file properties to
Excel?

I have looked at other posting son this subject and they seem to fall
short
with the filepath and file properties requirements.

Any advice much appreciated
Dave



  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 7
Default File path listing and analysis

Hi Bob

Apologies for not giving any feedback sooner, but Africa isn't great for
comms in places. I started looking at the FileSystemObject you suggested and
could not get it to work. I tried down an alternate route using the
FileSearch application and thought I had cracked it (see below) however I can
not get the LastModified part to work. Could you have a look and give me a
pointer or two? I have apostrophe'd out the parts that don't work.

I am new to programming and work very much on a trial and error basis so
please forgive me if the below is total garbage.

Many thanks
Dave

Private Sub FolderList()
Set fs = Application.FileSearch
With fs
.LookIn = "E:\MainFolder"
.SearchSubFolders = True
.Filename = "*.*"
' .LastModified = msoLastModifiedAnyTime
If .Execute() 0 Then
MsgBox "There were " & .FoundFiles.Count & _
" file(s) found."
For i = 1 To .FoundFiles.Count
Cells((i + 2), 2) = .FoundFiles(i)
' Cells((i + 2), 3) = .LastModified(i)
Next i
Else
MsgBox "There were no files found."
End If
End With
End Sub

"Bob Phillips" wrote:

Have you looked at using FileSystemObject to get those properties

Sub LoopFolders()
Dim oFSO
Dim Folder As Object
Dim Files As Object
Dim file As Object

Set oFSO = CreateObject("Scripting.FileSystemObject")

Set Folder = oFSO.GetFolder("C:\Folder1")

For Each file In Folder.Files
Debug.Print file.Path
Debug.Print file.DatelastModified
Next file

Set file = Nothing
Set Folder = Nothing
Set oFSO = Nothing
End Sub

--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my addy)



"DaveyC" wrote in message
...
Hi

I have two main folders with many sub-folders and files, one has to be
combined into the other ensuring that the most up to date file is adopted
whenever appropriate. In order to do this I thought the best way would be
to
down load or transfer complete filepaths and certain file properties (last
updated date) into Excel and analyse accordingly.

The structure of the two main folders differ.

Does anyone know how to transfer filepath lists and file properties to
Excel?

I have looked at other posting son this subject and they seem to fall
short
with the filepath and file properties requirements.

Any advice much appreciated
Dave




  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 7
Default File path listing and analysis

I think I have solved my own problem with the following code. Not
particularly pretty but it does the job. I combined the FileSearch function
with the FileSystemObject using the output of the former to feed the latter.

Hope this is of use to others

Best regards
Dave

Private Sub FolderList()
Set fs = Application.FileSearch
With fs
.LookIn = "E:\MainFolder"
.SearchSubFolders = True
.Filename = "*.*"
If .Execute() 0 Then
MsgBox "There were " & .FoundFiles.Count & _
" file(s) found."
For i = 1 To .FoundFiles.Count
Cells((i + 6), 2) = .FoundFiles(i)
Next i
Else
MsgBox "There were no files found."
End If
End With
Dim ft, d, f, s
For j = 1 To i - 1
Set ft = CreateObject("Scripting.FileSystemObject")
nf = Cells((j + 6), 2)
Set f = ft.GetFile(nf)
s = f.DateLastModified
Cells((j + 6), 3) = s
s = f.DateCreated
Cells((j + 6), 4) = s
Next j
End Sub

"DaveyC" wrote:

Hi Bob

Apologies for not giving any feedback sooner, but Africa isn't great for
comms in places. I started looking at the FileSystemObject you suggested and
could not get it to work. I tried down an alternate route using the
FileSearch application and thought I had cracked it (see below) however I can
not get the LastModified part to work. Could you have a look and give me a
pointer or two? I have apostrophe'd out the parts that don't work.

I am new to programming and work very much on a trial and error basis so
please forgive me if the below is total garbage.

Many thanks
Dave

Private Sub FolderList()
Set fs = Application.FileSearch
With fs
.LookIn = "E:\MainFolder"
.SearchSubFolders = True
.Filename = "*.*"
' .LastModified = msoLastModifiedAnyTime
If .Execute() 0 Then
MsgBox "There were " & .FoundFiles.Count & _
" file(s) found."
For i = 1 To .FoundFiles.Count
Cells((i + 2), 2) = .FoundFiles(i)
' Cells((i + 2), 3) = .LastModified(i)
Next i
Else
MsgBox "There were no files found."
End If
End With
End Sub

"Bob Phillips" wrote:

Have you looked at using FileSystemObject to get those properties

Sub LoopFolders()
Dim oFSO
Dim Folder As Object
Dim Files As Object
Dim file As Object

Set oFSO = CreateObject("Scripting.FileSystemObject")

Set Folder = oFSO.GetFolder("C:\Folder1")

For Each file In Folder.Files
Debug.Print file.Path
Debug.Print file.DatelastModified
Next file

Set file = Nothing
Set Folder = Nothing
Set oFSO = Nothing
End Sub

--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my addy)



"DaveyC" wrote in message
...
Hi

I have two main folders with many sub-folders and files, one has to be
combined into the other ensuring that the most up to date file is adopted
whenever appropriate. In order to do this I thought the best way would be
to
down load or transfer complete filepaths and certain file properties (last
updated date) into Excel and analyse accordingly.

The structure of the two main folders differ.

Does anyone know how to transfer filepath lists and file properties to
Excel?

I have looked at other posting son this subject and they seem to fall
short
with the filepath and file properties requirements.

Any advice much appreciated
Dave




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Formula too long - new file path is shorter than old file path - Excel 2003 Greg J Excel Worksheet Functions 1 November 22nd 06 05:16 PM
file path Jane Excel Discussion (Misc queries) 2 August 18th 06 03:03 PM
file path Jane Excel Discussion (Misc queries) 1 August 17th 06 05:08 PM
Excel updating from XML file - file path specific? Sean Excel Discussion (Misc queries) 4 August 5th 05 12:56 PM
Want file title listing as in Excel 5.0 File>Find jeffbro27707 Excel Discussion (Misc queries) 0 April 30th 05 07:31 PM


All times are GMT +1. The time now is 07:54 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"