Computing.Net > Forums > Programming > renaming files from excel databse

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to get for your free account now!

renaming files from excel databse

Reply to Message Icon

Name: fish
Date: January 14, 2009 at 05:01:06 Pacific
OS: Windows Vista
CPU/Ram: 3 gb
Manufacturer/Model: Dell / Inpiron 1525
Subcategory: Batch
Comment:

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


Report Offensive Message For Removal

Sponsored Link
Ads by Google

Response Number 1
Name: Mechanix2Go
Date: January 14, 2009 at 08:17:29 Pacific
Reply:

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


Report Offensive Follow Up For Removal

Response Number 2
Name: fish
Date: January 15, 2009 at 00:00:59 Pacific
Reply:

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 Offensive Follow Up For Removal

Response Number 3
Name: jon_k
Date: January 15, 2009 at 06:07:15 Pacific
Reply:

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 Offensive Follow Up For Removal

Response Number 4
Name: fish
Date: January 15, 2009 at 23:08:18 Pacific
Reply:

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


Report Offensive Follow Up For Removal

Response Number 5
Name: fish
Date: January 19, 2009 at 03:13:55 Pacific
Reply:

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 Offensive Follow Up For Removal

Related Posts

See More



Response Number 6
Name: reno
Date: January 21, 2009 at 01:58:08 Pacific
Reply:

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 Offensive Follow Up For Removal

Response Number 7
Name: fish
Date: January 21, 2009 at 23:57:52 Pacific
Reply:

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


Report Offensive Follow Up For Removal
Reply to Message Icon






Post Locked

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


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: renaming files from excel databse

Renaming files from txt within file www.computing.net/answers/programming/renaming-files-from-txt-within-file/17506.html

Renaming files from txt within file www.computing.net/answers/programming/renaming-files-from-txt-within-file/19181.html

Renaming files in Windows 98 & XP www.computing.net/answers/programming/renaming-files-in-windows-98-amp-xp/8057.html