How to use variables in file paths

Feb 19 2010

If you have tried entering a variable in a path:

you may have come across the following error: "File to copy not found", even though the variable contains the correct filename and extension.

In WinAutomation the percent (%) char is a delimiter for expressions (or variables) but the % combination equals to the literal % char. If, for example you want to display the message “50% of your disk is used”, you should write: “50\% of your disk is used”. In order to have a backslash and a % immediately after it (e.g. in a file path), you have to use the combination \%.

So, in this example:
C:My Files\%FileToCopy%  will not work while
C:My Files\\%FileToCopy% will work normally.

The reason for this behavior is that the backslash character is designed to behave like an escape character in case that you need to write the actual percent (%) character.

No votes yet

Comments

Samantha

posted on Fri, 03/04/2011 - 14:54

There was a mistake on the blog, it's now been corrected, you should actually be using C:\Documents and Settings\Administrator\My Documents\My Videos\\%FormattedDateTime% You can also check out this cookbook recipe here: http://www.winautomation.com/cookbook/i-want-use-symbol-any-field-i-cant :) Samantha
rahiltg

posted on Fri, 03/04/2011 - 08:46

I am using "If Folder" exists action and i want to see if the particular folder exists or not. This variable contains combination of date and time which makes it unique folder every time.

 

Like: 14/02/10 01:09:33 will be 14022010010933 and saved in %FormattedDateTime% variable.

 

When i use the condition like this:

C:\Documents and Settings\Administrator\My Documents\My Videos\14022010010933

 

it works fine.

 

But when i use "If Folder" exists action like this

 

C:\Documents and Settings\Administrator\My Documents\My Videos\%FormattedDateTime%

 

it doesn't work

 

need help please

Post your comment

You!
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <img> <p>
  • Lines and paragraphs break automatically.
  • Web page addresses and e-mail addresses turn into links automatically.
  • You may quote other posts using [quote] tags.

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.