Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hi
I have to rename a lot of files (GIS raster format) to new names. Is this what you would call Batch renaming? I have a database of all the old names, and what the new names should become.
typical Eg. name change from: reef_sp_eez_144_145_depth_20_200.rst
to:
kznfSpp144_09wdd.rst
So far I have been doing this manually in Microsoft Explorer.
Is there a script or programme that could do this for me?Thanks

If you save it as a CSV, it should be straightforward to script it. You may need to show excel what's what.
=====================================
If at first you don't succeed, you're about average.M2

Dear M2,
Excuse my ignorance - I am not clued up with computer scripts at all.
I will take the excel database, save only the relevant 2 columns next to each other as a CSV file.
Then to apply a script, which is a program that will take the filenames and change them to whatever the new name should be; info from the CSV file. - could you give me some guidance on the script that I should use?
Thanks so much

are all these files in the same directory?
If they are, you can insert a really simple VBA module on the spreadsheet (alt-f11, insert/module) and do it from there...
sub renamefiles() 'script to rename a bunch of files. Takes "was" filename from sheet1 column A, "new" filename from sheet1 column B. varleadingpath = "C:\" 'change to the relevant directory. for i = 2 to 100 'assumes 100 is the last row Name varleadingpath & sheet1.cells(i, 1).value As varleadingpath & sheet1.cells(i, 2).value Next i end subImportant - please *back up* the folder in question first.

Hey
All the files that I want to rename are in the same folder.
Does it matter if the one file name reappears several times? For example, I have a file called A and it applies to several records, but in the new file names it will be assigned a unique name, which it gets from Column B. I suppose I would need to make copies of A for as many times as it is needed, then change the names in the dbf - right?
And secondly - All of the records have at least two file name extensions associated with them. For example - AAA.shp; AAA.sbx; as GIS files typically have many files one describing the other.
Do I have to list all the associated file extensions in the table? /as I have not...Thanks ever so much
for your time

Thanks for your reply
I have realized that what I am trying to achieve may be to complicated, at least for me to try and figure out.
Thanks for now however.

what is it that you are trying to do?
give some more example file name in the excel files.
whats in column1 and whats in column2. is it column 1 contain file name to rename, and column 2 contain the new file name?if the filename is without extension, then for each filename.* found, what do you want to rename it to?
state your problem clearly.

Hey Reno
Thanks so much for your concern.
This problem has been sorted out now; These files were the same ones I wanted to rename in the previous question.So thanks again.
There is however another question with which I would like help. VB: EXcel: lookup Macro is the title of the question under programming. Any advice would be appreciated.Cheers

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |