Mass Delete Files based on an Excel Spreadsheet

MrFrantastic

New Member
Joined
Aug 2, 2023
Messages
1
Office Version
  1. 365
Platform
  1. Windows
Hey everyone. I'm having an issue getting rid of some old files. I have over 3700 pictures files (jpg & jpeg) saved on my network of current and former student ID photos. Each file is saved as a unique ID number. I have all of my current student ID numbers (about 1200) in an Excel spreadsheet. How can I use the current ID numbers to either delete the old/not in use pictures or find/move all the current picture files to a new folder?

Thanks!
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
Hello @MrFrantastic
This could be done using VBA if you accept that. Pure Excel cannot modify (or delete) files.
May I know a little bit more about your data?
Could you post an example of your spreadsheet? (You may change the names and IDs to something random)

I think it could work as follows:
First you sort your data (the current student IDs) in alphabetical (numerical) order, then you create a macro-enabled-spreadsheet (*.xlsm), create a macro (VBA code) and run it.
The macro would take the ID and look for the corresponding file (like ID 123456 -> 123456.jpg or 123456.jpeg, the extension can use wildcards) and move it to a directory of your choice.
In the end what's left are the IDs (picture files) you don't need.

If you accept using VBA and tell me more about your data I could write a macro that does the job.
 
Upvote 0

Forum statistics

Threads
1,223,239
Messages
6,170,947
Members
452,368
Latest member
jayp2104

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