Jump to content
Macro Express Forums

Count files in an Explore folder?


Recommended Posts

With a Windows XP Explorer folder open, is there a simple way to determine the number of files it contains please?

 

I can do it, but only by resorting to OCR capture!

 

It's easy enough to select all the entries and open a Properties window, which shows the number:

 

MEPro-CountFiles.jpg

 

But unfortunately that can't be easily copied to the clipboard.

 

--

Terry, East Grinstead, UK

Link to comment
Share on other sites

If you can move the mouse cursor over the information you want to capture, this code copies the information to a text variable, which can then be parsed.

 

Capture Control from Beneath the Mouse into %Control%
Get Control Text from %Control% into %Text%

 

A somewhat reliable hack -- is that enough of a contradiction? -- to move the cursor is to find out where the information is located in proportion to the window's width and height, e.g., as measured from the top left corner, 30% of the window's height, 10% of its width.

 

The information you want to capture is in different places on the propery screen in different versions of Windows. So forget about portability!

Link to comment
Share on other sites

Yes, thanks Paul, you're absolutely right. I realised last night that I could use the Repeat with Folder command to achieve what I wanted and I may well try it out of curiosity, as well as Alan's control-based approach.

 

However, I'd meanwhile decided to replace automatic counting with a Variable Set Integer > Prompt for value command. That gives me flexibility to choose a group of (successive) files, instead of the whole folder.

 

Background:

The original aim was to process large folders of JPGs, downloaded from my son's Flickr photostream. Unfortunately, I never see his photos named in the rigorous format I use, such as 20110920-123456.jpg or 20110920-123456-xyz.jpg for a photo taken today just before 12:35 pm. I'll settle for just the date if I have to, but names like DSC_6777-2-2.jpg are useless to me. Many of these photos eventually get used in my family DVDs, so chronology reigns! :)

 

Anyway, to get them into my format I open them in IrfanView and use its EXIF Date/Time data to rename them. My original approach was simply to work directly in the folder, top to bottom, so my macro started like this:

 

Macro Run: Count all entries in folder.
Variable Restore: Restore Integer Variables
Text Type (Simulate Keystrokes): <HOME><SPACE> // Select first entry.
Repeat Start (Repeat %nNumber% times)
 Text Type (Simulate Keystrokes): <ENTER> // Open in IrfanView.
 Delay: 1 seconds // (Wait for Window Title doesn't work.)
 Text Type (Simulate Keystrokes): ie // Opens EXIF Info window.
etc

 

Although fast to rattle off, that has various shortcomings: no filtering by file type; must remove any subfolders, and the thumbs.db that normally appears; processes all files, first to last. That last one was what made me switch to a prompted approach.

 

--

Terry, East Grinstead, UK

Link to comment
Share on other sites

Thanks Alan. That looks a fascinatingly different approach, and makes me really impatient to get stuck into using Controls much more. I'll experiment along those lines at the next similar opportunity.

 

See also some background in my reply to Paul.

 

Edit:

Curiosity got the better of me so I just tried it, but with the same lack of success I usually have with Controls!

 

Whatever type of Save setting I use in the Get Control, the result is always 'OK', presumably comes from the OK button in the Properties dialog, on which the mouse cursor finishes (not shown in screenshot).

 

MEPro-Controls-1.jpg

 

--

Terry, East Grinstead, UK

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...