Script question

Advanced Renamer forum
#1 : 31/07-24 16:21
Claus S
Posts: 1
I have a small script to rename files which fullfill some condition. How can I add a line to automatically remove the files which do not fullfill the condition - i.e. are not to be renamed, from the file list?

I would like to rename photos which have an EXIF date tag to something including the date and time (that part I got). When I run a huge bunch of images in the script, sometimes a lot do not have the exif tag and will not be renamed. What I want is to remove them from the list, so I only see the ones to be renamed, so i can check them before applying the change.

This is my script which I have stolen from another user here at this forum:

if (app.parseTags("<Img Year>")){
fName = app.parseTags("EXIF--<Img Year>-<Img Month>-<Img Day>_<Img Hour>-\
<Img Min>-<Img Sec>");
} else {
fName = item.name;
}
return fName;
#2 : 01/08-24 00:42
Delta Foxtrot
Posts: 324
Reply to #1:

Hi Claus,

There's no way that I know of to effect the number of filenames you see in the file list from within a script. You CAN right-click on the filename list and choose "Remove special / remove unchanged" to clear the items that are unchanged in the "New filename" column.

Best,
DF

EDIT: BTW, you can truncate that script to:

if (app.parseTags("<Img Year>")){
fName = app.parseTags("EXIF--<Img Year>-<Img Month>-<Img Day>_<Img Hour>-<Img Min>-<Img Sec>");
return fName;
}

You don't need the else clause. The script will automatically return the name passed to it if the "if" statement is not executed. It's not a big deal with < 100 filenames, but should be more efficient when a script touches ++ thousands of files.
And if you have "Settings/Renaming/Replace unsupported with:" set to a dash, you'll get the same results with fName = app.parseTags("EXIF--<DateTime>"); (you may have to check which exif fields contain the appropriate date+time information), instead of that long statement where you fit together several exif fields. That's got to be more efficient, right? The only difference is you'll have a space between date and time rather than the underscore.
I know, I know, it's not a big deal. Just something to think about. NOTE: I didn't test the speed differences of these, so I may be full of, well, mud. Or something worse. :)
END EDIT

edited: 01/08-24 02:20