Batch file to change file extensions

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
74,140
Office Version
  1. 365
Platform
  1. Windows
Barry was kind enough to help me write some Excel VBA script that will rename a text file with a ".prn" extension to a ".txt" extension ( http://www.mrexcel.com/board2/viewtopic.php?t=187679&highlight= ). This works great for new files being created, but I have to clean up a bunch of old files.

Can anyone help me write a Batch file (.bat) that I can run that will convert ALL existing "*.prn" extensions to "*.txt"?

The tricky part is that I need to do this without using the two step COPY then DELETE technique, as new "*.prn" files are being added all the time and I can't risk deleting one without changing it to a ".txt" (if one is being added while the batch file is running).

Thanks.
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
Barrie came through again!

From Barrie:
This worked for me.

Code:
rename *.prn *.txt

Note that the batch file was in the directory containing the files. Let me know the results you get.
 
Upvote 0

Forum statistics

Threads
1,224,862
Messages
6,181,466
Members
453,045
Latest member
Abraxas_X

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