Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×
The Claris Museum: The Vault of FileMaker Antiquities at Claris Engage 2025! ×

This topic is 5373 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

Hello,

In scriptmaster I found the script DeleteFileOrFolder ; I can't find how to pass jokers to delete all files in the folder without deleting the folder itself.

Indeed I saw that there's also a script to create folder, but it would be great if there's a possibility to perform that in only one command.

Thanks for your help !

Noël

Posted (edited)

I just played around with delete all day

If you create a script with the following code it passes the contents of a directory

// ListDirectory (fm)Directory)

// lists all files in a directory



def list = []

//eachFile() returns a list of objects

//is.Directory() returns if it is file or directory

new File(fm_Directory).eachFile{ if( it.isDirectory() ) {

	list == list

	} else {

	list<< it.absolutePath

	}

}



return list




it will give you back a list of {everything} all files



//edited this now gives system path so the next para is redundant

use Filemaker to loop through the list and remove every item that does not have a "." at the end and at the same time add the fm_Directory to the start of each value - am sure someone cleverer than me already might have code for that...





Then pass the resultant list to this




// Delete( fm_Filelist)

// param List() with valid system paths to files

// Deletes all the list

// Returns 2 if all done, 1 if partially done and 0 if no files deleted



files = (fm_Filelist)

list = files.split("n")

flag2 = 0

flag = 0

list.each { item -> 

File file = new File("${item}")

success = file.delete()

	if (!success) {

		flag2 = 1

	} else {

		flag = 1

	}

}

if ( flag2 == 1) {

	if (flag == 1 ) {

		return true

	} else {

		return false

	}

} else {

	return 2

}

this needs some work obviously but as you have got the list from a function in the first place it should only have legal values anyway

Edited by Guest
Posted

Hello John

Your solution works fine an I thank to to have "played" with that !

It requires also two scripts ; I imagined that it was possible to pass the list as a *.* or at least in my problem an *.jpg

Thanks and regards

Posted

That must be quite easy to do.

It should be possible to pass a file mask and then when the list is built to delete all members in one go. Will have a play tomorrow. Unless someone else wants to....

This topic is 5373 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.