Removing extracted files - Forum

Forum Navigation
You need to log in to create posts and topics.

Removing extracted files

I extract my Embedded files in [PubDir] by the following example code in order to use them in my publication :

ExtractFile "[Embedded]Pic1.jpg" "[PubDir]"

I want that these extracted files to be removed from [PubDir] after shutting down the publication. So, I check "Remove extracted files when publication terminates" option during compiling process. But the extracted files still exist in [PubDir] after shutting down the publication.

Does anyone have a solution?

@saeid

You can add the command to delete the desired files (FileErase) to the Shutdown tab in the project properties (Commands section).

The commands written on this tab will be executed just before you close your application.

saeid has reacted to this post.
saeid

@vadim

Thanks for your reply.

Your suggestion is the way that I'm using now. I'm searching for a way that publication automatically remove the extracted files. Because there are large number of extracted files and it needs hundreds lines of code to delete them.

I don't know if there is such a way?

Se me ocurre extraerlos en:

ExtractFile "[Embedded] Pic1.jpg" "[PubDir]/carpeta"

y al salir eliminar la carpeta entera.

 

saeid has reacted to this post.
saeid

Hello,

The option for automatic removel is for automatic extracted files (As far I know).

With command "Extractfile" you are responsible for the removing.

But why hundred lines of code?

Keep an array with all files including path and a counter-variable.

In shut down loop through the array and delete what you want.

This will be a few lines.

By the way: Extracting to PubDir is not a good idea. You can get problems with access-rights.

Regards

 

 

saeid has reacted to this post.
saeid

@jlash

Thanks a lot for your response.

@hpw

Hi,

Thanks for your response.

Would you please send me an example code of your suggested solution?

And what's your preferred location to extract my Embedded files instead of [PubDir]?

Hello,

Untested code idea:

ExtractFile "[Embedded]Pic1.jpg" "[TempDir]"
Setvar "[ExtractList1]" "Pic1.jpg"
Setvar "[ExtractCount]" "1"

ExtractFile "[Embedded]Pic2.jpg" "[TempDir]"
Setvar "[ExtractList2]" "Pic2.jpg"
Setvar "[ExtractCount]" "2"


.This code in Shutdown action
Loop "1" "ExtractCount" "[ExtractCounter]"
  FileErase "[TempDir][ExtractList[ExtractCounter]]"
EndLoop
saeid has reacted to this post.
saeid

Dear @hpw

Thanks for your help.