A folder contains no folders but multiple files.How can I delete these files using JSL?
Because this folder is occupied by other levels, cannot be achieved by deleting the folder.
rd1=Delete Directory(dir);rc1=Create Directory(dir);
Thanks!
If you want to just delete the files, here is a modification on @jthi code to do that
Names Default To Here( 1 ); dir_path = "$TEMP\test\"; If( !Directory Exists( dir_path ), Create Directory( dir_path ); new_file = Save Text File( dir_path || "DeleteMe.txt", "The quick brown fox" ); new_file = Save Text File( dir_path || "DeleteMe2.txt", "The quick brown fox" ); ); Wait( 1 ); // Get the files in the folder the_Files = Files In Directory( dir_path ); For Each( {file}, the_files, rc = Delete File( dir_path || file ) ); Show( Files In Directory( dir_path ) );
For me the directory gets deleted even if it has files. Maybe some of your files are still being used?
Names Default To Here(1); dir_path = "$TEMP\test\"; If(!Directory Exists(dir_path), Create Directory(dir_path); new_file = Save Text File(dir_path || "DeleteMe.txt", "The quick brown fox"); new_file = Save Text File(dir_path || "DeleteMe2.txt", "The quick brown fox"); ); wait(1); Show(Directory Exists(dir_path)); Show(Files In Directory(dir_path)); Show(File Exists(new_file)); Delete Directory(dir_path); wait(1); Show(File Exists(new_file)); Show(Directory Exists(dir_path));
I can't use Windows 7 anymore.
Be sure to use JMP 16.
Powerful For Each()
For Each( {file}, the_files, rc = Delete File( dir_path || file ) );