VBA Batch Renaming of Files

unknownymous

Board Regular
Joined
Sep 19, 2017
Messages
249
Office Version
  1. 2016
Platform
  1. Windows
Hi Excel Gurus,

I'm looking for some post here regarding naming of files but can't find a suitable one.

Basically I have these folders on my documents:

Folder 1: Math
Folder 2: Science
Folder 3: History

Inside the folders are different files like in the form of PDF, Excel, Text,jpg and Word. Example of files inside "Math folder":

Pupil1.xls
Pupil2.txt
Pupil3.docx
Pupil4.pdf

I was thinking to create a macro renaming the files by batch:

Macro Worksheet:

[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]Folder Name[/TD]
[TD]Folder Directory[/TD]
[TD]Date[/TD]
[TD]Macro Button[/TD]
[/TR]
[TR]
[TD]Math[/TD]
[TD]F:\User\unknown\Documents\Math[/TD]
[TD]063019[/TD]
[TD]Click Macro[/TD]
[/TR]
[TR]
[TD]Science[/TD]
[TD]F:\User\unknown\Documents\Science[/TD]
[TD]063019[/TD]
[TD]Click Macro[/TD]
[/TR]
[TR]
[TD]History[/TD]
[TD]F:\User\unknown\Documents\History[/TD]
[TD]063019[/TD]
[TD]Click Macro[/TD]
[/TR]
</tbody>[/TABLE]

Sample Output saved on the same folder (for Math):

Pupil1-Math-063019.xls
Pupil2-Math-063019.txt
Pupil3-Math-063019.docx
Pupil4-Math-063019.pdf

The Folder name was added= "-Math" & Date "-063019" in the file.


Any thoughts will be much appreciated. :)
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop

Forum statistics

Threads
1,223,228
Messages
6,170,871
Members
452,363
Latest member
merico17

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