PDA

View Full Version : Rename Multiple Files



psauber
08-10-2005, 09:53 AM
I have a table of stock codes and also a field
that references a picture with the name of a jpeg
to go with the stock code. What I need to do is to
rename the jpegs to the equivalent stock code. ie.
StockCode C894251 and relative jpeg is 987523.jpg
I need that jpeg to become C894251.jpg

Is there any VBA code that can do this.
Would appreciate any help

Thanks

xCav8r
08-10-2005, 06:32 PM
You need to rename them in the database, file system, or both?

On an unrelated note, are you really in the UK, or is your time zone just set incorrectly (to US West Coast time)?

psauber
08-10-2005, 11:53 PM
xCav8r

Tje jpegs are in a file on the hard disk. It is these files
I need to rename based on the stock codes in the
table. But I have a reference to these files in a field
in that same table.

I will check out the time zone

psauber
08-10-2005, 11:56 PM
Have check out all settings and all is OK

xCav8r
08-11-2005, 07:55 AM
I'm sorry. It's still unclear to me. Are you saying that you only need to rename the files in the file system, not in the database? And are you saying you have a table with a field that contains the path to these files and another field that has what they should be renamed?

The code you want would be pretty easy for me to create, but I need a clearer understanding of your table before I can do it.

If you're in San Francisco, your time zone is properly set. If you're in the UK, you should be GMT, not GMT-8. :old:

psauber
08-12-2005, 02:05 PM
xCav8r

Thanks for your reply

Yes, I need to rename the files that are on the hard disk.
The names I want to rename them to are in a table along
with the existing names of the files.
Apologies if I hadn't made my self clear enough. I'am pleased
to read that it will not be difficult to construct.

I await your reply

xCav8r
08-12-2005, 02:07 PM
Can you give me the table and field names and path to the folder containing the images?

jadedata
08-16-2005, 05:35 AM
You can use the Name statement. The below is not syntax/error checked but it should get you started in the right direction. Don't forget proper error traps in your code.

dim rs as dao.recordset

set rs=currentdb.openrecordset("Select PicName, StockCode From TableName;",dbopenforwardonly)

do until rs.eof
if len(dir$("D:filepath" & rs.picname,vbnormal))>0 then
name "D:filepath" & rs.picname "D:filepath" & rs.stockcode
end if
rs.move 1
loop


---
i consider the move to nameing the pictures with the stock a good move!
-j-

MOS MASTER
08-16-2005, 12:35 PM
Hi Jade, :yes

I think you've made a small typo?


name "D:filepath" & rs.picname "D:filepath" & rs.stockcode



Change to:
Name "D:filepath" & rs.picname As "D:filepath" & rs.stockcode

jadedata
08-16-2005, 12:59 PM
nice catch...but you didn't say


"Syntax error on line ???"

MOS MASTER
08-16-2005, 01:07 PM
nice catch...but you didn't say


"Syntax error on line ???"

A newby reading this post aint gonna comprehend the syntax explanation...that's why I marked it blue for easy reading

I make typo's all the time...and I guess we all do from time to time. :*)

jadedata
08-16-2005, 01:14 PM
<thanks> [subtle eastern style bow] </thanks>

MOS MASTER
08-16-2005, 01:15 PM
No Problem. :whistle: