Copy files once location has been found
Hey yall! I'm trying to write a little script that will find all the assets in my AE script that are associated with a file, and then copy said files to a new location but I seem to have hit a roadblock on the copy portion. My code runs and I'm getting the printout of all the locations of the assets but it doesn't seem to be translating to the copy, is there something obvious I'm missing? I'm including the script here as well. Thanks so much!
var assetLocos = getAssetLocations();
var assetLocations = new Array();
var assetArray = new Array();
var copyToLoco = new Folder("~/Desktop/main");
function getAssetLocations()
{
var array = [];
var array2 = [];
for(var i = 1; i <= app.project.numItems; i++)
{
if(app.project.item(i).mainSource)
{
if(app.project.item(i).mainSource.file)
{
array.push(decodeURI(app.project.item(i).mainSource.file));
}
}
}
return array;
}
for (var i = 0; i<assetLocos.length; i++)
{
$.writeln(assetLocos[i]);
copyFolder(assetLocos[i], copyToLoco,)
}
function copyFolder(sourceFolder, destinationFolder)
{
var sourceChildrenArr = sourceFolder
var sourceChild = sourceFolder;
var destinationChildStr = destinationFolder.fsName + "/" + sourceChild.name;
if (sourceChild instanceof File)
{
copyFile(sourceChild, new File(destinationChildStr));
}
}
function copyFile(sourceFile, destinationFile)
{
if (!sourceFile.copy(destinationFile))
{
if (!data.supressAlerts)
{
alert('Unable to copy\n' + sourceFile + '\nto\n' + destinationFile + '\nAborting.');
errors = true;
return false;
}
};
}
