Do you know a way to remove a folder with files and folders with FrameScript.
FrameScript doesn't remove non - empty folders.
you need to traverse folder hierarchy, delete files in any folder, and after that you can delete folders.
thanks, can you suggest a way how can i check it's a directory or a file ?
var currentFolder = srcFolder ;
var files = currentFolder.getFiles("*") ;
for (var i =0; i < files.length; i++)
if (typeof(files.copy) == "undefined")
Please note: Parameter of srcFolder must be of Type Folder...
Call for root folder is something like that:
DeleteDiretory(new Folder("Path to dir to remove"));
This should work. Good luck
but this is a extendscript, i need a framescript. thanks
this due to this is an ExtendScript forum.
Sorry, can't support you with FrameScript.
But may be you can port the logic.
I see you call DeleteDirectory whithin its own definition (line 10). Not clear how it works.
getFiles(*) delivers any content in this Folder, means sub-folders and files.
To check if an item in file-list is a directory, I check if this object has a copy-method (typeof(files.copy)=="undefined"). As only File objects have a copy-method, and File object with no copy-method is a sub-folder and I call DeleteDirectory for subfolders recursivly, delete files there and after that folder itself is deleted.
When all sub-folders are deleted, root folder is deleted
Hope this helps
I normally use a test on constructor.name - which is safer than testing for the copy method (a newer version of ExtendScript might actually introduce the copy method for a folder - who knows?).
if( files.constructor.name == "Folder" ) -- this does the actual test you want to do.
thanks for pointing me that way.
I wasn't aware of this way till I saw it one of your last sample Code.
That's the better way to check this, of course.