Jump to content
Macro Express Forums

Extract All Files Recursively Into One Directory


revivalfire

Recommended Posts

I want to get all the txt files out of a directory that has a bunch of subdirectories with txt files.

 

For instance.

C:\PLR\cats\cat1.txt

C:\PLR\cats\cat2.txt

C:\PLR\cats\cat2.txt

C:\PLR\dogs\dog1.txt

C:\PLR\dogs\dog2.txt

 

would be copied to

 

C:\ALL_PLR\cat1.txt

C:\ALL_PLR\cat2.txt

C:\ALL_PLR\cat3.txt

C:\ALL_PLR\dog1.txt

C:\ALL_PLR\dog2.txt

 

When I tried it, it seems to move the subdirectory folders too. I just want all the text files copied to one directory all together without being in subdirectory heirarchy. Thanks.

Link to comment
Share on other sites

I want to get all the txt files out of a directory that has a bunch of subdirectories with txt files.

 

For instance.

C:\PLR\cats\cat1.txt

C:\PLR\cats\cat2.txt

C:\PLR\cats\cat2.txt

C:\PLR\dogs\dog1.txt

C:\PLR\dogs\dog2.txt

 

would be copied to

 

C:\ALL_PLR\cat1.txt

C:\ALL_PLR\cat2.txt

C:\ALL_PLR\cat3.txt

C:\ALL_PLR\dog1.txt

C:\ALL_PLR\dog2.txt

 

When I tried it, it seems to move the subdirectory folders too. I just want all the text files copied to one directory all together without being in subdirectory heirarchy. Thanks.

 

I would suggest using the Repeat command called "Repeat with Folder".

 

Start with the folder C:\PLR\cats\

Make sure the radio button for "Files" is selectes (as opposed to Folders).

Also make sure the checkbox "Process Subfolders" is checked too.

 

The macro will then repeat through that directory (including subfolders) and return each FILE as a variable. Then inside your repeat, have a line of code that copies the variable (File Name) to your designated directory (ie: C:\ALL_PLR).

 

Add a 2nd repeat command for any other directories (ie: C:\PLR\dogs\).

 

Hope this helps.

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