Directory Contents Using MacID

jstevens
GoldLounger
Posts: 2640
Joined: 26 Jan 2010, 16:31
Location: Southern California

Directory Contents Using MacID

Post by jstevens »

I have been toying with Excel 2004 for the Mac and am having a challenge with the MacID. This should be straight forward but non-the-less I am stumpped. :hairout:

My goal is to read a directory for all JPEG files and produce a list. The challenge is that not all the JPEG files are being listed thus my confusion.

I have provided partial code and a picture of directory and list generated.

Code: Select all

    strFileName = Dir(oPath, MacID("JPEG"))
            
     While strFileName <> ""
        ActiveSheet.Range("A2").Offset(i, 0).Value = strFileName
        
        i = i + 1
        
        strFileName = (Dir)
        
     Wend


Thanks for taking a look,
John
You do not have the required permissions to view the files attached to this post.
Regards,
John

User avatar
John Gray
PlatinumLounger
Posts: 5497
Joined: 24 Jan 2010, 08:33
Location: A cathedral city in England

Re: Directory Contents Using MacID

Post by John Gray »

Hmmm - your MacID doesn't seem to match my concept of a MAC id!

Clearly we are suffering from Acronym Reuse Confusion (ARC)...
John Gray

I advise you not to follow my advice.​​

User avatar
HansV
Administrator
Posts: 79370
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Directory Contents Using MacID

Post by HansV »

Could you create a list of ALL files in the folder, with their MacID in the next column? Perhaps that would provide a clue.
Best wishes,
Hans

jstevens
GoldLounger
Posts: 2640
Joined: 26 Jan 2010, 16:31
Location: Southern California

Re: Directory Contents Using MacID

Post by jstevens »

John,

That is what I thought at first but the Mac is a little different when it comes to wildcards:

"The Dir function to check if certain files and directories exist. On the Macintosh, portions of the pathname are separated by colons instead of backslashes. Also, the Microsoft Windows wildcard characters are treated as valid file-name characters on the Mac. However, you can use the MacID function to specify file groups."

When I have an opportunity, I will revisit this and post my findings.

Hans - Your suggestion makes sense. Now I have to find out how to obtain the Mac Id of the file(s).

Boy do I feel like a Newbie.

Regards,
John
Regards,
John

jstevens
GoldLounger
Posts: 2640
Joined: 26 Jan 2010, 16:31
Location: Southern California

Re: Directory Contents Using MacID

Post by jstevens »

Hans,

I was able to produce a laundry list of all the files in a folder using "strFileName = Dir(oPath)". Please note that there is no reference to the MacID("JPEG").

In Column B, I recorded the MacID of each file. Unfortunately the MacId's are the same for the missing JPG files. If you recall, I only wanted a list of all JPG files.
untitled.png
This does not explain why I can't generate the JPG list per the code in my original post just adds a new twist to it.

Regards,
John
You do not have the required permissions to view the files attached to this post.
Regards,
John

User avatar
HansV
Administrator
Posts: 79370
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Directory Contents Using MacID

Post by HansV »

I'm afraid I have no idea what causes this, and I can't experiment since I don't have a Mac. I hope that someone who does can help.
Best wishes,
Hans

User avatar
rory
5StarLounger
Posts: 822
Joined: 24 Jan 2010, 15:56

Re: Directory Contents Using MacID

Post by rory »

Which version of (I assume) OSX are you using? Also, is your copy of 2004 fully updated?
If I get a chance I'll test your code tonight.
Regards,
Rory

User avatar
HansV
Administrator
Posts: 79370
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Directory Contents Using MacID

Post by HansV »

You're looking younger than ever, Rory! :innocent:
Best wishes,
Hans

User avatar
rory
5StarLounger
Posts: 822
Joined: 24 Jan 2010, 15:56

Re: Directory Contents Using MacID

Post by rory »

It's my approximation of the chocolate-face smiley that someone mentioned the other day! ;)
Regards,
Rory

jstevens
GoldLounger
Posts: 2640
Joined: 26 Jan 2010, 16:31
Location: Southern California

Re: Directory Contents Using MacID

Post by jstevens »

Hi Rory,

I'm using Snow Leopard with Excel 2004. I applied a workaround but don't know why I was encounter a partial list using the MacID("JPEG").

Here is my workaround:

Code: Select all

oType = ".JPG"

     While strFileName <> ""
        If InStr(UCase(strFileName), oType) > 0 Then
            ActiveSheet.Range("A2").Offset(i, 0) = strFileName
            ActiveSheet.Range("A2").Offset(i, 1) = MacID(strFileName)
            ActiveSheet.Range("A2").Offset(i, 2) = GetAttr(oPath & strFileName)
        End If
        
        i = i + 1
        
        strFileName = (Dir)
        
     Wend
This bit of code gets me to my happy place :yep:

Regards,
John

PS I thought it was a mustache albiet a chocolate one.
Regards,
John

User avatar
rory
5StarLounger
Posts: 822
Joined: 24 Jan 2010, 15:56

Re: Directory Contents Using MacID

Post by rory »

I've just run some tests and I can certainly replicate that (also Excel 2004 on Snow Leopard). The odd thing is that given a set of photos all taken with the same camera on the same day, it lists some but not others, and I can't see a common thread. I'll do some more research, but I think I'd stick with your workaround as Dir seems to be even less reliable on a Mac!
Regards,
Rory