Solved

Moving file and renaming them.

Posted on 2006-07-12
11
283 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: 17091225
0
 
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
 
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
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 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 …
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

920 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now