True, and in fact I couldn't get your latest version of script to work. I don't have enough experience to know why, but the one like it that I hacked does work. Thanks for helping me experiment and learn a bit!
Here‘s a version with a dialog that let‘s you name the new folder. It’s working for me, but if you get an error post a capture:
cleanLinks()
/**
* Moves the document links to a named folder
*/
function cleanLinks(){
var fn;
var d = app.dialogs.add({name:"Enter a New Folder Name", canCancel:true});
with(d.dialogColumns.add()){
fn = textEditboxes.add({editContents:" ", minWidth:250});
}
if(d.show() == true){
fn = fn.editContents
d.destroy();
}
var doc = app.activeDocument;
var dp = doc.filePath
var dl = doc.links.everyItem().getElements()
var nlf = new Folder(dp + "/" + fn);
nlf.create();
var lp
for (var i = 0; i < dl.length; i++){
lp = dl[i].filePath
dl[i].copyLink(nlf);
File(lp).remove();
};
alert("Links Have Been Moved to " + fn)
}