List / Delete content of local filemanager

Hi all,

I am reading and writing to / from the local filemanager on the iPhone and one of the days I got interested in the content of this application directory.

So I am sharing 2 scripts here, the first displays the result of a dir-command in the scriptable app log, the other one deletes all content from the local apps dir on the iPhone.

Although quite trivial, it helped me a lot. Hopefully some of you as well.

cheers!

fm.local_Dir.js

// Variables used by Scriptable.
// These must be at the very top of the file. Do not edit.
// icon-color: deep-gray; icon-glyph: camera-retro;
// Script by <kliffkieker67@gmail.com>
//
// Script list content of Scriptable App directory on iPhone

    let fm = FileManager.local();
    let dir = fm.documentsDirectory();

		let dir_array = fm.listContents(dir);
		for (let i=0; i<dir_array.length; i++){
			console.log("Entry " + (i+1) + ": " + dir_array[i]);  
		}

    Script.complete;

fm.local_DeleteAllFiles.js

// Variables used by Scriptable.
// These must be at the very top of the file. Do not edit.
// icon-color: light-gray; icon-glyph: camera-retro;
// Script by <kliffkieker67@gmail.com>

//
// Initialization der Variablen
//

    let fm = FileManager.local();
    let dir = fm.documentsDirectory();
//    let path = fm.joinPath(dir, scriptfile);

		let dir_array = fm.listContents(dir);
		for (let i=0; i<dir_array.length; i++){
			console.log("delete entry " + (i+1) + ": " + dir_array[i]);
			var path = fm.joinPath(dir, dir_array[i])
			fm.remove(path);
		}

Script.complete();