I have a folder of WAV files which may or may not always contain specific WAV files.
What I'm doing is to get the macro to open each file in the correct order by getting it to search for a specific file name. It does this by opening a 'Browse' window within a program and then in the file name field I enter the name of the file and then press Enter to select/open it.
The trouble is there are two files that won't always exist:
warning.wav
sponsor.wav
If they do exist then I want to select each one in turn but if they don't exist I want to skip over them and continue with the other files I need to select.
What is the best way of dealing with this?
I'm guessing that this will be require the use of If> of IfFileExists> but I'm not very familiar with their usage.
How to handle files that may not exist?
Moderators: JRL, Dorian (MJT support)
In the logic where you are selecting the files, add lines like:
IfFileExists>%Bounce%\Warning.wav
//Do what you do to open the file
Else
//Do what you do to skip the file
EndIf
But you could get that from help for IfFileExists>. I get the feeling you may be more concerned about the logic of the script. Can you post it or a snippet of it so we can take a look and perhaps be more helpful?
IfFileExists>%Bounce%\Warning.wav
//Do what you do to open the file
Else
//Do what you do to skip the file
EndIf
But you could get that from help for IfFileExists>. I get the feeling you may be more concerned about the logic of the script. Can you post it or a snippet of it so we can take a look and perhaps be more helpful?
This is what I have at the moment:
I suspect that the way I'm doing this isn't particularly elegant basically I'm opening a Browse window and navigating to the Bounce variable (thanks to your assistance in an earlier thread). This then presents me with a Browse window listing the contents of the relevant folder. For the first file, which we call Default TA, I'm simply entering default in the file name field. As this file will always exist it then highlights this WAV file and I can then just press enter to select it. Once this has done I then go back to the Browse Window to then look for the next file which if it exists, will be called sponsor.wav.
If it does exist I want to select it by locating it and pressing Enter. If it doesnt exist I want to search for the next file which will be called Details.wav and will always exist.
Hope that makes sense.
Code: Select all
//Get Talking Book Number
Input>TBnumber,Please Enter The Talking Book Number,
//Get Title of Book
Input>TBtitle,Please Enter The Full Title of The Book,
Let>INPUT_BROWSE=2
//Get Location of Bounced Files
Input>Bounce,Please Locate The Bounce Folder,F:\
Wait>2
Let>RP_WAIT=2
//Start EasePublisher
Run Program>C:\Program Files\Dolphin\EasePublisher211\EasePublisher.exe
SetFocus>EasePublisher
WaitWindowOpen>EasePublisher
//Create New Project From Audio Files
Press Ctrl
Send>n
Release Ctrl
Wait>1
Press Tab
Wait>0.5
Press Right *2
Wait>1
Press Enter
//Enter Title of Book for Project Name
WaitWindowOpen>Create new project wizard
SetFocus>Create new project wizard
Send>TBtitle
Wait>1
Press Enter
//Open Browse Window to locate WAV files
WaitWindowOpen>Create new project wizard
Wait>1
Press Enter
Wait>1
WaitWindowOpen>Select audio file(s) to your project
SetFocus>Select audio file(s) to your project
//Locate Bounce Folder and Import Default TA
Send>Bounce
Wait>1
Press Enter
Wait>1
Press Tab *8
Wait>1
Send>default
Wait>1
Press Enter
WaitWindowOpen>Create new project wizard
SetFocus>Create new project wizard
//Import Sponsor if it exists
If it does exist I want to select it by locating it and pressing Enter. If it doesnt exist I want to search for the next file which will be called Details.wav and will always exist.
Hope that makes sense.
There might be easier ways to do this but without experimenting with the software I can't be sure. One thing we CAN do to make this a little easier is: Since you know the name of the file you are seeking you should be able to incorporate the file name with the path (Bounce variable).
What you now have:
Could become:
Then on to the Sponsor file
Also I assume you know what to do to navigate from the "Create new project wizard" window back to the "Select audio file(s) to your project" window.
Hope this is helpful.
What you now have:
Code: Select all
//Locate Bounce Folder and Import Default TA
Send>Bounce
Wait>1
Press Enter
Wait>1
Press Tab *8
Wait>1
Send>default
Wait>1
Press Enter
WaitWindowOpen>Create new project wizard
SetFocus>Create new project wizard
Could become:
Code: Select all
//Locate Bounce Folder and Import Default TA
Send>%Bounce%\default
Wait>1
Press Enter
WaitWindowOpen>Create new project wizard
SetFocus>Create new project wizard
Then on to the Sponsor file
Code: Select all
//Import Sponsor if it exists
//Assuming Sponsor is a "WAV" file
IfFileExists>%Bounce%\Sponsor.wav
Send>%Bounce%\Sponsor
Else
Goto>SkipSponsor
EndIf
Wait>1
Press Enter
WaitWindowOpen>Create new project wizard
SetFocus>Create new project wizard
Label>SkipSponsor
//Import next file
Hope this is helpful.
Ahh yes I'm with you now
That does sound actually quite straight forward.
I'm slowly getting my head around this scripting lark so hopefully I'll be posting less and less simple problems. Part of my problem is that whilst I can understand the code that people such as you kindly suggest, when i'm actually presented with the options in MacroScheduler I get a little lost and confused.
I appreciate your help once again.
That does sound actually quite straight forward.
I'm slowly getting my head around this scripting lark so hopefully I'll be posting less and less simple problems. Part of my problem is that whilst I can understand the code that people such as you kindly suggest, when i'm actually presented with the options in MacroScheduler I get a little lost and confused.
I appreciate your help once again.