first file in the directory

Advanced Renamer forum
#1 : 28/08-19 19:55
mike
mike
Posts: 19
hi there,

when adding folders for renaming , I can also add files included in these folders, based on some criteria.

Is there any way to add the first file from the folder only ? (files have different names patterns) )


28/08-19 19:55
#2 : 29/08-19 17:14
David Lee
David Lee
Posts: 1125
I can think of a method if you are prepared to load only one folder at a time - by loading the entire contents of the folder and using a script to rename only the first item in the list.

eg for a very simple rename:

if (app.currentIndex == 0){
name_0 = "Fred";
return name_0;
}

This will cycle through all the files in the list but only rename the first one.

An alternative method that will only access the first file would be to use a blank script then load and rename just the first item, from the Pre batch script:

eg (in the Pre batch script):

item_0 = app.getItem(0);
name_0 = "Fred";
item_0.newName = name_0 + item_0.ext;

Then click Close and apply script (no need to Apply the main script).

In principle the second method may be expected to run faster if there is a large number of files in the folder. However I've no idea whether it will make any difference in practice.


29/08-19 17:14 - edited 29/08-19 17:22
#3 : 30/08-19 12:06
mike
mike
Posts: 19
Reply to #2:
thanks david.
unfortunately the idea is to load many folders at a time and pick up from them the first file only.
So far i am using regex which covers majority of file names patterns


30/08-19 12:06