Improve company productivity with a Business Account.Sign Up

x
?
Solved

Moving file and renaming them.

Posted on 2006-07-12
11
Medium Priority
?
297 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
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
What Kind of Coding Program is Right for You?

There are many ways to learn to code these days. From coding bootcamps like Flatiron School to online courses to totally free beginner resources. The best way to learn to code depends on many factors, but the most important one is you. See what course is best for you.

 
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 750 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

What Kind of Coding Program is Right for You?

There are many ways to learn to code these days. From coding bootcamps like Flatiron School to online courses to totally free beginner resources. The best way to learn to code depends on many factors, but the most important one is you. See what course is best for you.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

This article will show how Aten was able to supply easy management and control for Artear's video walls and wide range display configurations of their newsroom.
When you discover the power of the R programming language, you are going to wonder how you ever lived without it! Learn why the language merits a place in your programming arsenal.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
Simple Linear Regression

607 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