Solved

Moving file and renaming them.

Posted on 2006-07-12
11
289 Views
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.
0
Comment
Question by:jodyreid
[X]
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
11 Comments
 
LVL 11

Expert Comment

by:MacNuttin
ID: 17091694
0
 
LVL 11

Expert Comment

by:MacNuttin
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
0
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!

 
LVL 4

Expert Comment

by:v_karthik
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 www.activeperl.com)

http://www.employees.org/~vkarthik/downloads.html#bulkrename

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

Author Comment

by:jodyreid
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

AA019.tifA

Why is this happening.
Thank you.

0
 

Author Comment

by:jodyreid
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.
0
 
LVL 25

Expert Comment

by:SStory
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)
        Next
0
 
LVL 11

Expert Comment

by:MacNuttin
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
0
 

Author Comment

by:jodyreid
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
cls
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
to
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
0
 
LVL 11

Accepted Solution

by:
MacNuttin earned 250 total points
ID: 17103651
nice solution glad to help
0
 
LVL 1

Expert Comment

by:almondmitchell
ID: 17117885
Imports system.io

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

Featured Post

Independent Software Vendors: 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!

Question has a verified solution.

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

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
Starting up a Project

689 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