|
Answer» I have a requirement to change the "Title" field of a few thousand JPG files. Each file will have a different title.
I have all the data in a spreadsheet so creating the individual commands will be easy once I have the syntax.
If it's not possible then I'm open to suggestions about how to do it any other way.
Thanks,
Ian.Batch is not the tool to use for this.
Extended file attributes (Title) can be accessed through the Shell Application but can only be changed through the DSO object. The spreadsheet presumably can be accessed through the Excel Application.
Check out the DSO object. If in fact the spreadsheet is Excel and you decide to install DSO, we can probably hobble together a VBScript to HELP you out.
I believe Irfanview can do batch RENAMING of picture files...Patio,
I've had a look at Irfanview and although it has a batch facility it doesn't allow the use of an input file containing the required data changes. Thanks for the idea though.
Sidewinder,
your suggestion looks like the way forward but I'm afraid I have no experience of coding Object Oriented Languages so I would need to be spoon fed.
As I say I can create an Excel spreadsheet with the file path/names and the Title data.
If you have the time/desire to write a script that would be great but I will understand if you have better things to do.
Ian.
Had to make certain assumptions, but nothing is etched in granite.
Spreadsheet layout:
column A - contains fully qualified path of the file column B - contains new title
Code: [Select]Set dso = CreateObject("DSOFile.oleDocumentProperties") Set xlApp = CreateObject("Excel.Application") Set xlBook = xlApp.Workbooks.Open("c:\scripts\book1.xls") 'path to spreadsheet Set xlSheet = xlBook.Worksheets("Sheet1")
Set objRange = xlSheet.UsedRange rowCount = objRange.Rows.Count
For k = 1 To rowCount strFile = xlApp.Cells(k,1) dso.Open(strFile) dso.SummaryProperties.Title = xlApp.Cells(k,2) dso.Save Next
xlApp.Quit
If I guessed wrong on the specs, we can make changes otherwise the script framework should be correct.
Note: For whatever reason, I had to boot after INSTALLING DSO.
Sidewinder,
we're almost there. The first file's title is changing but I'm getting an "unspecified error" Code "80004005" script error.
I'm guessing it's a security issue but I've played around with it and haven't got anywhere.
I'm using Windows XP, I've made the folder a shared folder and allowed network users to change my files.
When I try to access the spreadsheet after a failure I'm told ADMIN has a lock on it and I can only go in on a read-only basis.
Any ideas.
Thanks for all your help so far,
Ian.Quote When I try to access the spreadsheet after a failure I'm told ADMIN has a lock on it and I can only go in on a read-only basis.
Normally when I post a script, I leave out the error trapping so as to reduce the code clutter. Unfortunately this can backfire if the script aborts, leaving objects hanging around in the system. This is not always fatal, but when the object is an automation server like Excel, it can create conflicts. The usual solution is to use the task manger to clean out the running instances of the objects.
Of course if I hadn't gotten ahead of myself the script would have worked the first time out.
This corrected script version should fix you right up:
Code: [Select]Set dso = CreateObject("DSOFile.oleDocumentProperties") Set xlApp = CreateObject("Excel.Application") Set xlBook = xlApp.Workbooks.Open("c:\scripts\book1.xls") 'path to spreadsheet Set xlSheet = xlBook.Worksheets("Sheet1")
Set objRange = xlsheet.UsedRange rowCount = objRange.Rows.Count
For k = 1 To rowCount strFile = xlApp.Cells(k,1) dso.Open(strFile) dso.SummaryProperties.Title = xlApp.Cells(k,2) dso.Save dso.Close() Next
xlApp.Quit Set xlSheet = Nothing Set xlBook = Nothing Set xlApp = Nothing
Good luck. That works a treat!
Thanks a lot Sidewinder, you've saved me a whole world of pain.
Ian.
|