<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to delete all files in a folder? in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/How-to-delete-all-files-in-a-folder/m-p/550987#M76709</link>
    <description>&lt;P class=""&gt;&lt;SPAN class=""&gt;Thanks!&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=""&gt;&amp;nbsp;&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN class=""&gt;I can't use Windows 7 anymore.&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN class=""&gt;Be sure to use JMP 16.&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN class=""&gt;Powerful For Each()&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;For Each( {file}, the_files, rc = Delete File( dir_path || file ) );&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 29 Sep 2022 23:16:46 GMT</pubDate>
    <dc:creator>lala</dc:creator>
    <dc:date>2022-09-29T23:16:46Z</dc:date>
    <item>
      <title>How to delete all files in a folder?</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-delete-all-files-in-a-folder/m-p/550708#M76676</link>
      <description>&lt;P&gt;A folder contains no folders but multiple files.&lt;BR /&gt;How can I delete these files using JSL?&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Because this folder is occupied by other levels, cannot be achieved by deleting the folder.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;rd1=Delete Directory(dir);rc1=Create Directory(dir);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2023 15:59:20 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-delete-all-files-in-a-folder/m-p/550708#M76676</guid>
      <dc:creator>lala</dc:creator>
      <dc:date>2023-06-09T15:59:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to delete all files in a folder?</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-delete-all-files-in-a-folder/m-p/550753#M76678</link>
      <description>&lt;P&gt;For me the directory gets deleted even if it has files. Maybe some of your files are still being used?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;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));

&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 29 Sep 2022 11:58:48 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-delete-all-files-in-a-folder/m-p/550753#M76678</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2022-09-29T11:58:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to delete all files in a folder?</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-delete-all-files-in-a-folder/m-p/550774#M76679</link>
      <description>&lt;P&gt;If you want to just delete the files, here is a modification on&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/14366"&gt;@jthi&lt;/a&gt;&amp;nbsp;code to do that&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;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 ) );&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 29 Sep 2022 12:33:48 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-delete-all-files-in-a-folder/m-p/550774#M76679</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2022-09-29T12:33:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to delete all files in a folder?</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-delete-all-files-in-a-folder/m-p/550987#M76709</link>
      <description>&lt;P class=""&gt;&lt;SPAN class=""&gt;Thanks!&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=""&gt;&amp;nbsp;&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN class=""&gt;I can't use Windows 7 anymore.&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN class=""&gt;Be sure to use JMP 16.&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN class=""&gt;Powerful For Each()&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;For Each( {file}, the_files, rc = Delete File( dir_path || file ) );&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 29 Sep 2022 23:16:46 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-delete-all-files-in-a-folder/m-p/550987#M76709</guid>
      <dc:creator>lala</dc:creator>
      <dc:date>2022-09-29T23:16:46Z</dc:date>
    </item>
  </channel>
</rss>

