Avatar of Roberto Madro R.
Roberto Madro R.
Flag for United States of America asked on

File Extension change

This is suppose to be straightforward but it's not, I need to change the file extension using a batch job on files with .txt extension to .bak, what the simplest way.

Thx
Windows BatchMicrosoft DOS

Avatar of undefined
Last Comment
Roberto Madro R.

8/22/2022 - Mon
Shizzo

All .TXT files?
Roberto Madro R.

ASKER
Yes,

And that's my issue, I need to retain the name(s) of the file(s) but only change their extension.
Bill Prew

At a command prompt you can just do this from that folder:

REN *.TXT *.BAK

~bp
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
SOLUTION
Bradley Fox

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Roberto Madro R.

ASKER
NO, "Ren" expects a literal in the second half of the command, "*. etc." works well with Delete, Copy, etc., not with "Ren"
Shizzo

ren *.txt *.bak will work if they are all in one folder.
Roberto Madro R.

ASKER
How do I invoke this?
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Roberto Madro R.

ASKER
How do I call up this vbscript?
Bradley Fox

Open Notepad and paste the code in then save it with a .vbs extension.  To call it just double click it.

You can call it from the command line too

cscript.exe C:\Path\To\Script.vbs

Open in new window

Bill Prew

The command I suggested will certainly work fine, here's an example.

C:\Temp\ee>dir
 Volume in drive C is Windows 7
 Volume Serial Number is 0000-0000

 Directory of C:\Temp\ee

12/27/2012  01:17 PM    <DIR>          .
12/27/2012  01:17 PM    <DIR>          ..
12/27/2012  01:17 PM                 2 1.txt
12/27/2012  01:17 PM                 2 2.txt
12/27/2012  01:17 PM                 2 3.txt
               3 File(s)              6 bytes
               2 Dir(s)   4,508,450,816 bytes free

C:\Temp\ee>ren *.txt *.bak

C:\Temp\ee>dir
 Volume in drive C is Windows 7
 Volume Serial Number is 0000-0000

 Directory of C:\Temp\ee

12/27/2012  01:17 PM    <DIR>          .
12/27/2012  01:17 PM    <DIR>          ..
12/27/2012  01:17 PM                 2 1.bak
12/27/2012  01:17 PM                 2 2.bak
12/27/2012  01:17 PM                 2 3.bak
               3 File(s)              6 bytes
               2 Dir(s)   4,508,454,912 bytes free

Open in new window

~bp
Your help has saved me hundreds of hours of internet surfing.
fblack61
Roberto Madro R.

ASKER
Thanks, it worked,

Can I call a .vbs from a batch file (I'm thinking I should be able to), what do you think?

Thx
SOLUTION
Bradley Fox

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
ASKER CERTIFIED SOLUTION
Bill Prew

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Roberto Madro R.

ASKER
In good hands with EE, Thanks to both of you "mcsween" & "billprew".