Rename files with specific extension pattern

August 17, 2009 at 20:16:43
Specs: Windows XP
I’ve searched the forums on this site & couldn’t find anything conclusive. I need a DOS batch command similar to the one below to add a '.tif' extension to multiple files that have a specific pattern in their extension.

The DOS batch command line:
for %%i in (*.????????) do ren %%i %%i.tif

For example, rename *.20080902 to *.20080902.tif in the same directory as the batch file.

The only problem is that the above script renames all files in the directory (including the batch file 'ren2tif.bat').

The script needs to SKIP files that DO NOT have the 8-digit numeric format (i.e., *.yyyymmdd) in the extension.

Any ideas?

See More: Rename files with specific extension pattern

Report •

August 18, 2009 at 00:44:32
Try using a bit more detail in the extension e.g. *.2008????

Report •

August 18, 2009 at 17:04:40

That worked. The solution looks so obvious now.

I changed the the batch file as follows:
for %%i in (*.20??????) do ren %%i %%i.tif

This will rename any file produced this century. These are simply TIF images that get churned out by a CAD program & uploaded to a unix server. I needed this script to work for Windows so we can review/print drawings before uploading them to our unix server. Some projects may over a hundred drawings so renaming them one by one is not practical!

To rename them back I just use:
ren *.20*.tif *.

Report •

Related Solutions

Ask Question