cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • JMP will suspend normal business operations for our Winter Holiday beginning on Wednesday, Dec. 24, 2025, at 5:00 p.m. ET (2:00 p.m. ET for JMP Accounts Receivable).
    Regular business hours will resume at 9:00 a.m. EST on Friday, Jan. 2, 2026.
  • We’re retiring the File Exchange at the end of this year. The JMP Marketplace is now your destination for add-ins and extensions.

Discussions

Solve problems, and share tips and tricks with other JMP users.
%3CLINGO-SUB%20id%3D%22lingo-sub-550708%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%C2%BFC%C3%B3mo%20eliminar%20todos%20los%20archivos%20de%20una%20carpeta%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-550708%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EUna%20carpeta%20no%20contiene%20carpetas%20sino%20varios%20archivos.%3CBR%20%2F%3E%20%C2%BFC%C3%B3mo%20puedo%20eliminar%20estos%20archivos%20usando%20JSL%3F%3C%2FP%3E%3CP%3E%3CBR%20%2F%3EDebido%20a%20que%20esta%20carpeta%20est%C3%A1%20ocupada%20por%20otros%20niveles%2C%20no%20se%20puede%20lograr%20eliminando%20la%20carpeta.%3C%2FP%3E%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3Erd1%3DDelete%20Directory(dir)%3Brc1%3DCreate%20Directory(dir)%3B%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%C2%A1Gracias!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-550708%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CLINGO-LABEL%3Esecuencias%20de%20comandos%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3Eventanas%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-550753%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%3A%20%C2%BFC%C3%B3mo%20eliminar%20todos%20los%20archivos%20de%20una%20carpeta%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-550753%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EPara%20m%C3%AD%2C%20el%20directorio%20se%20elimina%20incluso%20si%20tiene%20archivos.%20%C2%BFQuiz%C3%A1s%20algunos%20de%20sus%20archivos%20todav%C3%ADa%20se%20est%C3%A1n%20usando%3F%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3ENames%20Default%20To%20Here(1)%3B%0A%0Adir_path%20%3D%20%22%24TEMP%5Ctest%5C%22%3B%0A%0AIf(!Directory%20Exists(dir_path)%2C%0A%20Create%20Directory(dir_path)%3B%0A%20new_file%20%3D%20Save%20Text%20File(dir_path%20%7C%7C%20%22DeleteMe.txt%22%2C%20%22The%20quick%20brown%20fox%22)%3B%0A%20new_file%20%3D%20Save%20Text%20File(dir_path%20%7C%7C%20%22DeleteMe2.txt%22%2C%20%22The%20quick%20brown%20fox%22)%3B%0A)%3B%0A%0Await(1)%3B%0AShow(Directory%20Exists(dir_path))%3B%0AShow(Files%20In%20Directory(dir_path))%3B%0AShow(File%20Exists(new_file))%3B%0A%0ADelete%20Directory(dir_path)%3B%0A%0Await(1)%3B%0A%0AShow(File%20Exists(new_file))%3B%0AShow(Directory%20Exists(dir_path))%3B%0A%0A%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-550774%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%3A%20%C2%BFC%C3%B3mo%20eliminar%20todos%20los%20archivos%20de%20una%20carpeta%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-550774%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3ESi%20solo%20desea%20eliminar%20los%20archivos%2C%20aqu%C3%AD%20hay%20una%20modificaci%C3%B3n%20en%3CA%20href%3D%22https%3A%2F%2Fcommunity.jmp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F14366%22%20target%3D%22_blank%22%3E%20%40jthi%3C%2FA%3E%20c%C3%B3digo%20para%20hacer%20eso%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3ENames%20Default%20To%20Here(%201%20)%3B%0A%0Adir_path%20%3D%20%22%24TEMP%5Ctest%5C%22%3B%0A%0AIf(%20!Directory%20Exists(%20dir_path%20)%2C%0A%20Create%20Directory(%20dir_path%20)%3B%0A%20new_file%20%3D%20Save%20Text%20File(%0A%20%20dir_path%20%7C%7C%20%22DeleteMe.txt%22%2C%0A%20%20%22The%20quick%20brown%20fox%22%0A%20)%3B%0A%20new_file%20%3D%20Save%20Text%20File(%0A%20%20dir_path%20%7C%7C%20%22DeleteMe2.txt%22%2C%0A%20%20%22The%20quick%20brown%20fox%22%0A%20)%3B%0A)%3B%0A%0AWait(%201%20)%3B%0A%0A%2F%2F%20Get%20the%20files%20in%20the%20folder%0Athe_Files%20%3D%20Files%20In%20Directory(%20dir_path%20)%3B%0A%0AFor%20Each(%20%7Bfile%7D%2C%20the_files%2C%20rc%20%3D%20Delete%20File(%20dir_path%20%7C%7C%20file%20)%20)%3B%0A%0AShow(%20Files%20In%20Directory(%20dir_path%20)%20)%3B%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-550987%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%3A%20%C2%BFC%C3%B3mo%20eliminar%20todos%20los%20archivos%20de%20una%20carpeta%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-550987%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%20class%3D%22%22%3E%3CSPAN%20class%3D%22%22%3E%C2%A1Gracias!%3C%2FSPAN%3E%3C%2FP%3E%3CP%20class%3D%22%22%3E%26nbsp%3B%3C%2FP%3E%3CP%20class%3D%22%22%3E%3CSPAN%20class%3D%22%22%3EYa%20no%20puedo%20usar%20Windows%207.%3C%2FSPAN%3E%3C%2FP%3E%3CP%20class%3D%22%22%3E%3CSPAN%20class%3D%22%22%3EAseg%C3%BArese%20de%20utilizar%20JMP%2016.%3C%2FSPAN%3E%3C%2FP%3E%3CP%20class%3D%22%22%3E%3CSPAN%20class%3D%22%22%3EPoderoso%20para%20cada%20uno%20()%3C%2FSPAN%3E%3C%2FP%3E%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3EFor%20Each(%20%7Bfile%7D%2C%20the_files%2C%20rc%20%3D%20Delete%20File(%20dir_path%20%7C%7C%20file%20)%20)%3B%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FLINGO-BODY%3E
Choose Language Hide Translation Bar
lala
Level IX

How to delete all files in a folder?

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!

1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: How to delete all files in a folder?

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 ) );
Jim

View solution in original post

3 REPLIES 3
jthi
Super User

Re: How to delete all files in a folder?

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));

-Jarmo
txnelson
Super User

Re: How to delete all files in a folder?

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 ) );
Jim
lala
Level IX

Re: How to delete all files in a folder?

Thanks!

 

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 ) );

Recommended Articles