Skip navigation
Currently Being Moderated

Remove parent folder and all subfolders (custom info panels)

Jan 11, 2012 9:40 PM

Tags: #subfolder #scripts #folder_structure #file_info_panels

I'm writing a script to help users install custom info panels in the Folder.userData + '/Adobe/XMP/Custom File Info Panels/3.0/panels' location.  I have a working script to copy files, but I also want to delete previous versions of the same info panel.   I also want to allow for the possibility that could be several older versions so I need to loop through them.  I know that I need to empty the files of a folder before it can be removed.  I can remove one instance of a ninfo panel, but not several - I'm having trouble getting the function to loop.

 

For example, if I have two old info panel version to delete (myPanel_v1 and myPanel_v2) can use getFiles (myPanel*) to get an array with the names of the two parent folders:

~/AppData/Roaming/Adobe/XMP/Custom%20File%20Info%20Panels/3.0/panels/m yPanel_v1,~/AppData/Roaming/Adobe/XMP/Custom%20File%20Info%20Panels/3. 0/panels/myPanel_v2

 

What I can't do is the loop through the subfolders and their contents based on the index of this array.  Perhaps there is a completey different approach I need to take?

 

 

The code below does remove a single instance of my custom ino panel, but I can't figure out a way to make it loop.

 

var CS5panelsFolder = (Folder.userData + '/Adobe/XMP/Custom File Info Panels/3.0/panels');

var xmask = 'myPanel*'

var xRemove =  (Folder (CS5panelsFolder).getFiles (xmask));  // returns an array with all folders with 'VRA_beta' in the name

for (var i = 0; i < xRemove.length; i++) var xBin = (Folder (xRemove[i]+'/bin').getFiles());

for (var i = 0; i < xRemove.length; i++) var xLoc = (Folder (xRemove[i]+'/loc').getFiles());

for (var i = 0; i < xRemove.length; i++) var xRes = (Folder (xRemove[i]+'/resources').getFiles());

 

for (var i = 0; i < xRemove.length; i++)

{

    //Loop through array of xBin files and remove them

    for (var i = 0; i < xBin.length; i++) File(xBin[i]).remove();

    //Loop through array of loc files and remove them

    for (var i = 0; i < xLoc.length; i++) File(xLoc[i]).remove();

    // Loop through array of resource files and remove them

    for (var i = 0; i < xRes.length; i++) File(xRes[i]).remove();

    // remove manifest file

    for (var i = 0; i < xRemove.length; i++) File(xRemove[i]+'/manifest.xml').remove();

}

 

for (var i = 0; i < xRemove.length; i++)

{

// Remove now empty xBin folder

    for (var i = 0; i < xRemove.length; i++) Folder(xRemove[i]+'/bin').remove();

// Remover now empty loc folder

    for (var i = 0; i < xRemove.length; i++) Folder(xRemove[i]+'/loc').remove();

// Remove now empty resources folder

    for (var i = 0; i < xRemove.length; i++) Folder(xRemove[i]+'/resources').remove();

// Remove now empty old version folder

    for (var i = 0; i < xRemove.length; i++) Folder(xRemove[i]).remove();

}  

 

 

Thanks for your help,

 

Greg Reser

 
Replies

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points