Quantcast
Channel: Alfresco Forums - Other APIs
Viewing all articles
Browse latest Browse all 74

Replace part of an existing file name

$
0
0

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.


Viewing all articles
Browse latest Browse all 74

Trending Articles