batch rename all .txt in all subdirectories

October 23, 2010 at 05:29:29
Specs: Windows XP, 4gb
hey experts,
how do i rename all .txts in all subdirectories of a drive?

See More: batch rename all .txt in all subdirectories

Report •

October 23, 2010 at 08:44:24
Try this:

FOR /f "tokens=*" %%a IN ('DIR /b /s *.txt') DO (
	REN "%%a" "NewName.txt"

Can I put a question here?

Report •

March 14, 2011 at 13:09:47

I tried your suggestion but I don't think I know enough about batch files to get it to work properly.

@echo off
FOR /f "tokens=*" %%a IN ('C:\Documents and Settings\name\folder\data\*.txt') DO (
REN "%%a" "datafile.txt"

I have a folder that I populate with a .txt file daily. I download them from an ftp server to that folder and I want a batch file to take the file and convert it from whatever the file name is to another file name.

Ex. dataFile03032011 --> datafile
dataFile03042011 --> datafile
dataFile03052011 --> datafile

The reason I'm doing this is because I'm trying to automatically upload a delimited txt file into MS Access table which is hard when the file name is constantly changing. So I want to rename it to a constant file name so access knows what it is and can automatically populate a table. I'm currently doing all of this manually and I would like to make it an automated process.

Any help would be great!

Zach C.

Report •

March 14, 2011 at 14:25:54
Like Matt123 said;

FOR /f "tokens=*" %%a IN ('DIR /b /s C:\Documents and Settings\name\folder\data\*.txt') DO (
REN "%%a" "NewName.txt"

Happy is ONE who says I am an OttoMAN.

Report •
Related Solutions

Ask Question