Jump to content
Macro Express Forums

Count Files In A Folder And Copy A Few


burt

Recommended Posts

Can this be done with Macro Express.

 

In Windows Explorer i have folders with i.e. 100 files (digital photo's).

 

I want to make a macro which first counts the number of files in a folder and then makes a copy of (i.e.) 5 files to another directory. It shouldnt be the first 5 files but i.e. the first, the 26th, 51th, 76th and the last file.

 

The files do not always have logical filenumbers in the filename.

 

Is this possible?

 

Thanks, Burt

Link to comment
Share on other sites

Hello Burt!

 

Yes, you can do this. Are you basing which files to copy strictly on the file count, date added, or something in the file name sequence? Also, what are your plans for copying the next time? Do you start fresh, or do you check if a file has already been copied?

Link to comment
Share on other sites

Well, I have many folders with large photosets and I want to make a folderset with only a few samples of what I photographed. Then I can quickly look in a folder to see a representation of the photo's without having to wait until all metadata is read in the original folders. These are quite large files so it takes a while to load (6-13Mb per photo).

 

The foldernames are as descriptive as possible.

The subfolderset with the copies can have the same name as the original folders.

 

I don't base the file copy on something special, the file numbers are not increasing linear, but they jump (gaps in the names exist due deleting photo's in the camera itself). I just would like to have a macro which first counts how many files are in the directory and then copy those 5 with regular intervals. So not 5 in a row but taken from the whole directory with more or less regular intervals. The filecount is not needed if there is another wat to do it.

 

No special plans for copying and how to handle the next time.

 

For each existing (or new) folder I would like to make a backup folder with these 5 copies. A check to see which folders have to be done or already been done is nice but not very needed at first because it might get too difficult for me ;-)

 

 

Thanks again,

Burt

Link to comment
Share on other sites

Burt,

 

You can use the Repeat with Folder command to loop through all files in a specific folder. You could use one repeat loop to count the files and another to 'process' them, like this:

Variable Set Integer %N1% to 0
Repeat with Folder
 Variable Modify Integer: Inc (%N1%)
Repeat End
// Here, N1 contains the number of files in the folder

Repeat with Folder
 Variable Set From File Path

 // Put commands here to process the filenames

Repeat End

The Variable Set From File Path command allows you to copy the filename without its path or extension into a separate variable. You could then add macro commands to make the determination which files to copy.

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...
×
×
  • Create New...