Move files to folders based on two criteria in the extension name

gxm204

New Member
Joined
Nov 20, 2015
Messages
29
I have a task here that might be possible with VBA or VBScript. I did the first couple of steps with VBA but I am not sure how to proceed.

I am downloading annual reports from the SEC which I want to group in folders by their respective year and SIC code. I am doing this with the EDGAR package in R.
EDGAR has this filename convention -- Screenshot of file name format: https://drive.google.com/file/d/0B4GKNSEDe65tSjRUSTVfT2xOaTg/view?usp=sharing

I have a mapper of CIK code to SIC code. Screenshot of company ID to SIC mapper: https://drive.google.com/file/d/0B4GKNSEDe65tNnJobzk3Z0RQR1k/view?usp=sharing


Ultimately I would like to move all of these files into separate folders by SIC code.
I was able to create all the SIC code folders by adapting this code a bit: https://www.reddit.com/r/excel/comments/5uhp4i/create_multiple_folderssubfolders_based_on_data/

So I have a Folder "3825," "3350," and so forth.

Now I want to move all these files into these folders. I imagine the steps would be something like:


  1. Extract the CIK code from file extension (essentially everything before the first "_")
  2. Find the corresponding SIC code from my master list
  3. Move that file into the corresponding folder




Thanks for taking a look. It is like a batch processing job, certainly new to me, so any suggestions welcome.

Best, George
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce

Forum statistics

Threads
1,214,905
Messages
6,122,178
Members
449,071
Latest member
cdnMech

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top