Moving file and renaming them.

Posted on 2006-07-12
Last Modified: 2006-11-18
I have about 10,000 file that I need to move and rename. Is there a way with a batch file that i could move x amount of these files and rename them at the same time. This is what i need to do. I have about 60-70 with the name AA091.tif , AA092.tif and so on. I need to put a letter at the end of all thes file " AA091A, AA092A and so on" Then i have 60-70 in another folder that i need to move and rename but the have th esame name e.g. " AA091.tif and i need to rename these AA091B.tif and so on.
I have about 10 folder with about 10,000 file. I do not want to go and rename each file one by one.
Thank you.
Question by:jodyreid
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 11

Expert Comment

ID: 17091225
LVL 11

Expert Comment

ID: 17091694
LVL 11

Expert Comment

ID: 17092135
To put in a batch file, and I've tested this, it moves and renames with "old" prefix

@echo off
for %%i in (*.tif) do move %%i new/path/old%%i
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


Expert Comment

ID: 17092364
I wrote a perl script for this long back .. mainly to rename my digital photos in one shot ... You can download and use it if you have perl (u can get it for free from

If you are using it let me know if you have trouble.

Author Comment

ID: 17092526
These are not helping much. This is how i am renaming the files but it does not work very well.
@echo off
Ren R:\test\A*.* A*A.*  

the end result is that instead of getting
from this AA019.tif   to AA019A.tif
i am getting


Why is this happening.
Thank you.


Author Comment

ID: 17092983
This will rename all the file name to old. I just want to add A to the end of the file name. (AA019.tif change to AA019A.tif). I have 10 different folders a,b,c,d and so on with the same file name in each e.g in the A folder i have AA019.tif and in the B folder i have AA019.tif and so on. I need to just add the letter of the folder to the end of the file name.
Is this possible with batch code.
Thank you.
LVL 25

Expert Comment

ID: 17094318
Well if you have VB2005,

something similar to this could be tweaked to rename the files. You could make a console app to do it if you like or just
hard code and run.

        'change c:\ to appropriate directory; tif is set to be the only type of files renamed..change as desired
        'this is quickly done and not tested, but you should get the idea
        Dim Files() As String = System.IO.Directory.GetFiles("c:\", "*.tif")
        Dim fi As FileInfo
        For Each S As String In Files
            fi = New System.IO.FileInfo(S)
            System.IO.File.Move(fi.FullName, fi.Name & "A" & fi.Extension)
LVL 11

Expert Comment

ID: 17094723
The point is with my code in a bat file and change the "old" to "A" ,the new/path to your directory and it will do what you what except it puts the "A" at the beginning of the filename. Sorry - play with it a little and maybe you can get the A or B or whatever where you want it

Author Comment

ID: 17100370
Thank you but this is what i have done. I am going to take it in two stages.
1. I am going to Rename all the file.
This is the batch file I have
@echo off
Ren R:\ECHART\A\F*.tif F??????A.tif
@echo on

This puts the A at the end of the file name but i have to change the the batch every time for all the leters i.e.
'Ren R:\ECHART\A\F*.tif F??????A.tif
Ren R:\ECHART\A\G*.tif G??????A.tif and so on. Is the a way to have it this change the letter for me with out changing the Batch file.
2. I am going to copy the files over after i change the Name.
Thank you
LVL 11

Accepted Solution

MacNuttin earned 250 total points
ID: 17103651
nice solution glad to help

Expert Comment

ID: 17117885

File.Move("d:\source", "c:\destination")

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.
Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question