You are not logged in.
Pages: 1
Hello,
when renaming files form my camera I have different types of files and would like to handle them based on the extension. For example:
*.jpg should be renamed based on their EXIF creation date
*.mp4 filesshould be renamed based on their file modification date.
Can this be done in one run. I mean without selecting the files first and then running different scripts on them?
Best Regards
Offline
I think yes, by utilizing PascalScript:
http://www.den4b.com/wiki/ReNamer:Rules:PascalScript
http://www.den4b.com/wiki/ReNamer:Pascal_Script
http://www.den4b.com/wiki/ReNamer:Pasca … e_and_Time
Such script will be executed for each file.
Just get the extension on each file and then "IF...THEN" extract the date and create a new file name pattern to rename current file.
Read the *WIKI* for HELP + MANUAL + Tips&Tricks.
If ReNamer had helped you, please *DONATE* to Denis or buy a PRO license. (Read *Lite vs Pro*)
Offline
Also required: http://www.den4b.com/wiki/ReNamer:Pasca … Extraction
Offline
Sweet, thanks Andrew!
I had now time at my launch break and developed a POC script. Please test if that works for you.
var
sExte, sDate: WideString;
begin
sDate := '1981-01-01 00.00.00';
sExte := WideExtractFileExt(FilePath);
if( WideUpperCase(sExte) = '.JPG') then
begin
//ShowMessage( 'JPG : : : EXIF - ' + FileName )
sDate := CalculateMetaTag(FilePath, 'EXIF_Date') // YYYY-MM-DD HH.MM.SS
sDate := copy(sDate,1, 10); // YYYY-MM-DD
end;
if( WideUpperCase(sExte) = '.MP4') then
begin
//ShowMessage( 'MP4 : : : mod date - ' + FileName )
//sDate := FormatDateTime( 'yyyy-mm-dd hh.MM.ss', FileTimeModified(FilePath) );
sDate := FormatDateTime( 'yyyy-mm-dd', FileTimeModified(FilePath) );
end;
//new file name is sDate + - + old file name:
FileName := sDate + ' - ' + FileName;
end.
If yes, please consider donation to Denis. Thanks
Read the *WIKI* for HELP + MANUAL + Tips&Tricks.
If ReNamer had helped you, please *DONATE* to Denis or buy a PRO license. (Read *Lite vs Pro*)
Offline
Great. Stefan and Andrew: Thanks a lot. Your code worked almost out the box. I only made some minor modifications since my EXIF data seems to come in a different flavour.
I also use the "fix conflicting new names" option but would like to get rid of the braces and the space (e.g "filename (2)" --> "filename-2"). I achieved that with a second run that with a simple replace/remove action set. Is there a more elegant way to achieve this in one run?
btw: just got myself a Pro license. I like ReNamer
var
sExte, sDate: WideString;
begin
sDate := '1981-01-01 00.00.00';
sExte := WideExtractFileExt(FilePath);
if( WideUpperCase(sExte) = '.JPG') then
begin
//ShowMessage( 'JPG : : : EXIF - ' + FileName )
sDate := CalculateMetaTag(FilePath, 'EXIF_Date') // YYYYMMDD-HHMMSS
sDate := copy(sDate,1, 15); // YYYYMMDD-HHMMSS
FileName := sDate + sExte;
end;
if( WideUpperCase(sExte) = '.MOV') then
begin
//ShowMessage( 'MP4 : : : mod date - ' + FileName )
//sDate := FormatDateTime( 'yyyy-mm-dd hh.MM.ss', FileTimeModified(FilePath) );
sDate := FormatDateTime( 'yyyymmdd-hhMMss', FileTimeModified(FilePath) );
FileName := sDate+sExte;
end;
//new file name is sDate + - + old file name:
//FileName := sDate + ' - ' + FileName;
end.
Offline
I also use the "fix conflicting new names" option but would like to get rid of the braces and the space (e.g "filename (2)" --> "filename-2"). I achieved that with a second run that with a simple replace/remove action set. Is there a more elegant way to achieve this in one run?
You can enable the "Fix conflicting new names" option permanently in the Settings, in Preview tab. This will let you do everything in a single run. There is also another way for doing this, via Pascal Script (bundled "serialize duplicates" script), but using standard rules is more efficient than using scripts.
btw: just got myself a Pro license.
Thanks for your support!
Offline
Pages: 1