Jump to content
Macro Express Forums

How to select certain amount of files in a folder?


Recommended Posts

I want to create a macro script where if there are more than 61 files in a folder it would separate the files into more folders so that there are no more than 61 files in each folder. 

Let's say I have 235 files in THE folder that's currently open & active. Macroexpress already knows there are 235 files. How do I select first 61 of them, cut them, create folder1 outside of the current folder and paste those 61 files into Folder1, then go back into the folder select another 61 files, create Folder2 outside of the folder paste the second set of 61 files into Folder2, and repeat the process until there are no longer more than 61 files in the folder? 

Link to comment
Share on other sites

My advice is to never use Windows File Explorer to manipulate files with MEP. Instead use MEP's built in file manipulation commands. Using the Repeat With Folder command and an integer variable as a counter it would be simple to do what you want. 

Link to comment
Share on other sites

I got it... The only reason I used "current file window" because that's how I encounter there are more than 61 files in the folder. And to process it I press a shortkey so it can start filtering the file count, then come out of that folder and try to process other folders, if any. The folder locations and names will always vary, this is why I have a command to start process the current folder. It won't process through file explorer!!! It's only to indicate macroexpress which folder path to work with. But I can't figure out that "simple" algorithm to process the folders... How do I cut first 61 files in an %T1% folder, then place those files in outside of the folder within Folder%N2%... what's the command for that? 

Link to comment
Share on other sites

You're not clear on how you want it to work exactly. If the source folder has 61 or fewer, do nothing. Then you say if it has greater than 61 to move it into more folders with no logic. Say there are 100 files in folder A. Extras will move to BN where N is the folder number. The result could be:

  1. A = 39, B1 = 61
  2. A = 61, B1 = 39
  3. B1 = 61, B2 = 39.

Which is it?

Link to comment
Share on other sites

Without knowing the answer to my last question, I can give a basic framework and you can tweak to your needs. Let's assume the answer is #3.

I would use a Repeat With Folder command. I would create an integer variable %Counter% and an integer %FolderNumber% = 1. I would then iterate though the file list, moving the files to "B" + %FolderNumber%. When %Counter% = 62, I would reset the counter to 1 and increment %FolderNumber%.

As an aside, if you know the file extension, use that as a filter. You might also want to add a condition to skip hidden files to avoid things like thumbs.db. 

Link to comment
Share on other sites

What I want to do is this:

Let's say I have 250 files in folderX I want macroexpress to create FolderX1 and place 61 files out of folderX then FolderX2 another 61 out of folderX... and keep going until in FolderX there are no more than 61 files left. Hence the folderX would be broken down to FolderX1, FolderX2, etc so that there are no more than 61 files per each folder, in the parent folder where FolderX is located... The only extension of files is .rx2 There will be no other extensions in the folders. The information you're providing is the idea of how it may work, but not the actual commands that would run such functions. I'm a newbie in macroexpress, and I'm looking for actual commands that would perform such functions. And in help file I couldn't find these commands that's why I'm here 

 

Thanx

Link to comment
Share on other sites

I already know how to get total amount of files in a given folder. Let's say it's assigned to %N1% = 250

I would divide %N1% / 61 then assign the number to %N2% as a number of times to loop. But what are the commands that would count first 61 files and move them into a FolderX%N2%

Link to comment
Share on other sites

See Cory's first reply -- command "Repeat with Folder".  Something like this:

Variable Set Integer %N99% to 0 [counter]
Repeat with Folder [each time through the loop, Macro Express puts the name of the "next" file into variable %T1% or whatever text variable you want to use] 
  Variable Modify Integer: Inc (%N99%) [increment counter]
  If Variable %N99% > 61 [exit from loop after 61 file moves]
    Repeat Exit
  End If
  Move File or Files: "%T1%" [move one file]
Repeat End

Use the Macro Express Help screens to read about these commands. 

Link to comment
Share on other sites

On 7/30/2018 at 2:32 PM, USslang said:

Let's say I have 250 files in folderX I want macroexpress to create FolderX1 and place 61 files out of folderX then FolderX2 another 61 out of folderX... and keep going until in FolderX there are no more than 61 files left. Hence the folderX would be broken down to FolderX1, FolderX2, etc so that there are no more than 61 files per each folder, in the parent folder where FolderX is located... The only extension of files is .rx2 There will be no other extensions in the folders. The information you're providing is the idea of how it may work, but not the actual commands that would run such functions. I'm a newbie in macroexpress, and I'm looking for actual commands that would perform such functions. And in help file I couldn't find these commands that's why I'm here 

So in my example, #2. Correct?

I'm sorry I don't have time to write the macro for you. I am available for hire at reasonable rates if you like. Between rberg and I we have given you commands to explore. Part of learning is reading the documentation on a command, and experimenting with it. Go create a macro with Repeat With Folder like I suggested in my first message and see how far you get. If you get stuck show us what you have and we can advise from there. 

Also if I have mentioned a command you don't know what it is, please let me know. Sometimes we get so used to what we do we don't see our omissions. But I think most are self explanatory. I mentioned increment an integer variable. Well... Let's think about that. Look at the variable commands. You should be able to guess that Variable Modify Integer might be it. And you would be correct. Now your curious mind should be exploring this command's methods. Add... subtract... Oh look!  At the bottom. "Increment" and "Decrement". Easy and fun! 

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...