PDA

View Full Version : Conditional 'if file folder exists'



JDG
04-29-2013, 01:35 PM
I think I might be duplicating myself when testing for the existence of a folder in an installer.

Suppose I want to check if a folder c:\MyFolder exists on the target system and if so copy a subfolder and the subfolder's files into it.

In Script Editor do I need to 2 if exist statements ie one for the subfolder's creation and another for the files in the subfolder?

As an extension to this I'd ideally like to check for the existence of c:\MyFolder and if it does not exist offer the user a browse option so that they can select an alternative location.

Even better is there a condition check option in the Visualizer or does all this type of logic have to be in the script editor?

Thanks in advance

John

linder
04-30-2013, 01:06 AM
John,

You can add an "If X Folder exists Then" Statement to see if a specific folder exists on the target machine.

Then you can use the "Copy File(s)..." script function with the "Do not overwrite existing files" option enabled (if you do not want to overwrite existing files) to copy the files from one folder to another. You can also use the "Copy Folder Tree..." script function to handle it.

You can use the "If X Folder exists Then" Statement to see if a specific folder exists on the target machine. If this is not the case, just display a standard "Select Install Folder" or a Custom Wizard Dialog with folder browse option.

This type of logic always have to be in the Script Editor. From the technical point-of-view, there is no way to handle this from a Visualizer.

Friedrich

JDG
04-30-2013, 03:59 AM
Hi Friedrich,

Thanks for the quick reply.


John,

You can add an "If X Folder exists Then" Statement to see if a specific folder exists on the target machine.

Then you can use the "Copy File(s)..." script function with the "Do not overwrite existing files" option enabled (if you do not want to overwrite existing files) to copy the files from one folder to another. You can also use the "Copy Folder Tree..." script function to handle it.

With this approach would the files still be removed with the uninstaller?


You can use the "If X Folder exists Then" Statement to see if a specific folder exists on the target machine. If this is not the case, just display a standard "Select Install Folder" or a Custom Wizard Dialog with folder browse option..

Just to clarify on the 'If X folder exists Then' statements. If I'm creating a folder and also copying files to it are there 2 'If Then' statements needed; one for the folder creation and one to add the files to the folder?


This type of logic always have to be in the Script Editor. From the technical point-of-view, there is no way to handle this from a Visualizer.

Point taken, makes sense :)

Thanks again,

John

linder
04-30-2013, 07:24 AM
Hi John,


With this approach would the files still be removed with the uninstaller?

If you have the "Remove on Uninstall" option enabled, then yes :)


Just to clarify on the 'If X folder exists Then' statements. If I'm creating a folder and also copying files to it are there 2 'If Then' statements needed; one for the folder creation and one to add the files to the folder?

You only need one 'If X folder exists Then' statement to check if the folder exists. If it does not exist, create it and then copy the folder(s) and file(s).

Friedrich

JDG
04-30-2013, 11:43 AM
Thanks Friedrich,

I was a little confused as to whether I needed to check for the existence of the file/folder around the create folder or copy files sections of the script or both :)

On a totally unrelated question; is it possible to stop the folder trees expanding automatically when making changes in Files/Folders in the visualizer?

John