Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

List a file attributes

Status
Not open for further replies.

3wsparky

IS-IT--Management
May 25, 2003
121
GB
Hi all have this code that lists all files in a folder but wanted to have an option to state the file im looking for
ie E:\_Music\mp3\Enigma\The Cross Of Changes\remix.mp3
the following script will just rattle its way through the whole dir, guessing i need to spec the filename and alter the fl but i have had no joy trying to do this , think its quite simple but im simple when it comes to vbs

Sub Main

On Error GoTo Err_1

'***** Read files from selected folder (Directory) *****
Set fs = CreateObject("Scripting.FileSystemObject")

Set dirfolder = fs.GetFolder("E:\_Music\mp3\Enigma\The Cross Of Changes\")

'***** Read files *****
For Each fl In dirfolder.Files

aName = fl.name
aSize = Format(Int(fl.Size / 1024) + 1, "###,###,### KB")
aType = fl.type
aDC = Format(fl.DateCreated, "mm/dd/yyyy")
aDLA = Format(fl.DateLastAccessed, "mm/dd/yyyy")
aDLM = Format(fl.DateLastModified, "mm/dd/yyyy")
aTitle = fl.title
aArtist = fl.Artist
aAlbumTitle = fl.AlbumTitle
aGenre = fl.Genre

MsgBox ":" & aName & ":" & vbCrLf _
& ":" & aSize & ":" & vbCrLf _
& ":" & aType & ":" & vbCrLf _
& ":" & aDC & ":" & vbCrLf _
& ":" & aDLA & ":" & vbCrLf _
& ":" & aDLM & ":" & vbCrLf _
& ":" & aTitle & ":" & vbCrLf _
& ":" & aArtist & ":" & vbCrLf _
& ":" & aAlbumTitle & ":" & vbCrLf _
& ":" & aGenre & ":" & vbCrLf

Next fl

'On Error GoTo Err_1
Exit_1:
Exit Sub

Err_1:
MsgBox "********** In Subroutine Main ********** " & vbCrLf & vbCrLf & Error$
Resume Exit_1

End Sub
 
>but wanted to have an option to state the file im looking for
ie E:\_Music\mp3\Enigma\The Cross Of Changes\remix.mp3

Don't understand what is "to state". What does it mean?

These types of construction are not supported in vbs: [1] "On Error GoTo Err_1", [2] "Exit_1:" and "Err_1:", [3] "Next f1".
 
rather than listing all the files within the folder i want to pick / select a file in the script to check rather than all
 
Simply add a parameter to your procedure.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top