1.

Solve : Rename files with specific extension pattern?

Answer»

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?ok, so this is a PRETTY sloppy way because it does not cover the whole 8 digit thing, but just finds if the files have 2008 or 200x in it.

Code: [Select]ren "*.2008*" "*.2008*.tif"
ren "*.2009*" "*.2009*.tif"
using asterisks to fill in the "void" of numbers will find all files with the "pre" file as a guide.

or, if i am wrong. please correct mekeep in mind, a rename of a pic.jpg to pic.tif does not change the format of the picture. The picture remains a jpg picture.

There are conversion programs that will change the format. And almost any image editor will allow you save a picture as a new format.

p.s. Until you are pleased with the new name use copy instead of ren or move. Good luckCode: [Select]for %%i in (*.2???????) do ren %%i %%i.tif
that should do it Thanks,

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 *.



Discussion

No Comment Found