#1 2006-09-03 15:14

fjord
Member
From: Denmark
Registered: 2006-08-25
Posts: 43

Rename "buddy" files, like .thm, produced by digital camera

My digital (still) camera takes video clips, saved in .avi files. The camera also saves a .THM files with the same name, which provides metadata to the camera's software. I have seen such auxiliary files referred to as "buddy files". (was that here?)

If I rename the .avi file, then I would like the .thm file to be renamed with the same name, so they can continue to be used together.

This would be easy, until I rename the .avi with a name that includes AVI_width and AVI_height, which aren't defined for the .thm file.  Does ReNamer have a way to handle renaming of buddy files, including situations where the new filename can't be directly constructed from the buddy file's own original name?

Offline

#2 2006-09-04 13:13

den4b
Administrator
From: den4b.com
Registered: 2006-04-06
Posts: 3,367

Re: Rename "buddy" files, like .thm, produced by digital camera

Yes, that can be done smile

You can add a PascalScript rule at the end of your preset, which will check the original FilePath variable, to see if it has a "buddy file". If it's there, rename the "buddy file" to the new name of the current file using the FileName variable and the WideRenameFile function.

Are you familiar with Delphi programming language? If not, I can write it for you...

Offline

#3 2006-09-04 13:48

fjord
Member
From: Denmark
Registered: 2006-08-25
Posts: 43

Re: Rename "buddy" files, like .thm, produced by digital camera

I wrote alot of TurboPascal many years ago, but went on to other things before Delphi came out.

If you could point me to some example code referring to FileName, I could probably take it from there.

Offline

#4 2006-09-04 21:49

den4b
Administrator
From: den4b.com
Registered: 2006-04-06
Posts: 3,367

Re: Rename "buddy" files, like .thm, produced by digital camera

Below is the code to rename the buddy files with the THM extension. Tell me how it goes, ok? smile

NOTE: buddy files will be renamed on the Preview, since the rule will be applied on the Preview! So when you add this rule, make sure you unmark it while testing your rules set, and only when you are ready to rename, mark this last rule back on, and rename.

const
  BUDDY_EXT = '.thm';

var
  NewName, Buddy, NewBuddy: WideString;

begin
  Buddy := WideChangeFileExt(FilePath, BUDDY_EXT);  
  if WideFileExists(Buddy) then
    begin
    NewName := WideExtractBaseName(FileName);
    NewBuddy := WideExtractFilePath(FilePath) + NewName + BUDDY_EXT;
    WideRenameFile(Buddy, NewBuddy);
    end;
end.

Offline

#5 2006-09-04 22:05

fjord
Member
From: Denmark
Registered: 2006-08-25
Posts: 43

Re: Rename "buddy" files, like .thm, produced by digital camera

Thanks, Denis. I'll try it tomorrow.

Offline

#6 2006-09-07 18:12

dloneranger
Senior Member
From: Birmingham, UK
Registered: 2006-05-03
Posts: 122

Re: Rename "buddy" files, like .thm, produced by digital camera

A function like 'IsPreview' could come in handy in these situations, eg: if not IsPreview then WideRenameFile(Buddy, NewBuddy);

'Preview proofing' all the calls that could actually do something would be a more user friendly way, but until we have 40 hour days there are usually better things to do <grin>

Offline

#7 2007-01-10 15:13

den4b
Administrator
From: den4b.com
Registered: 2006-04-06
Posts: 3,367

Re: Rename "buddy" files, like .thm, produced by digital camera

dloneranger wrote:

A function like 'IsPreview' could come in handy in these situations, eg: if not IsPreview then WideRenameFile(Buddy, NewBuddy);

Unfortunately, your suggestion is impossible to implement. This is because "Rename" action DOES NOT execute the rules, it simply renames files from current name to whatever specified in the New Name field. It is only for the "Preview" action the rules get executed, in order to generate new names.

P.S. "Preview" button should really be called "Generate" hmm

Offline

Board footer

Powered by FluxBB