AnsweredAssumed Answered

Replace part of an existing file name

Question asked by kevin33 on Apr 19, 2016
Hi,
thanks to this forum I successfully adapted to my needs a simple script for ranaming files that are uploaded through a folder rule

var folderName = document.parent.parent.parent.parent.parent.parent.name;
var folderName1 = document.parent.name;
//var docName = document.name;
var date = new Date();
var timeInMillisecs = date.getTime();
var ISODate = timeInMillisecs;
document.name = folderName + " " + folderName1 + " " + timeInMillisecs;
document.save()

I have this script in various folders to achive the desired change in name.

Now I have the problem that the foldername in future could change name so I would have the files already uploaded with "wrong" (old foldername name) names.
So I think I would need something that check the name of the newly renamed folderName and that for every existing file in folder renames just the part of the folderName of the exsisting files, keeping the rest of the name the same.
Is that possible? thst's outside my area of expertise.
Thanks in advance.

Outcomes