renaming files from excel databse

Dell / Inpiron 1525
January 14, 2009 at 05:01:06
Specs: Windows Vista, 3 gb

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

So far I have been doing this manually in Microsoft Explorer.
Is there a script or programme that could do this for me?


See More: renaming files from excel databse

Report •

January 14, 2009 at 08:17:29
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.


Report •

January 15, 2009 at 00:00:59
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

Report •

January 15, 2009 at 06:07:15
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 sub

Important - please *back up* the folder in question first.

Report •

Related Solutions

January 15, 2009 at 23:08:18

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

Report •

January 19, 2009 at 03:13:55
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.

Report •

January 21, 2009 at 01:58:08
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.

Report •

January 21, 2009 at 23:57:52
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.


Report •

Ask Question