In Applescript, I use the below to get a folder on my desktop whose name ends with "PROOF" (the folders full name name is: A123456-PROOF ), it then removes the characters "-PROOF" leaving me with A123456, How would this be done usingextendscript?, can I get some help and pointers with this please? cheers Kev
set _folders to (folders of desktop whose name ends with "PROOF")
repeat with _folder in _folders
set _Name to name of _folder
set name of _folder to (characters 1 thru -7 of _Name as text)
end repeat
Iv'e looked at "split", but i'm not sure how to use it properly
Something like this?
var folders = Folder.desktop.getFiles("*-PROOF");
while (f = folders.pop()) f.rename(f.name.split('-')[0]);
Or here is the almost exact translation of your code:
var folders = Folder.desktop.getFiles("*PROOF");
for (var i=0; i<folders.length; i++) {
var new_name = folders[i].name.slice(0,7);
folders[i].rename(new_name);
}