Page 1 of 1

Relative Path

Posted: Mon Dec 05, 2016 9:56 am
by jchapman01
I have a move command that takes in a variable for the source file. I was hoping to set the destination folder to be relative to that file. If there anyway to do that?

Thanks.

Re: Relative Path

Posted: Mon Dec 05, 2016 10:04 am
by Support_Rick
Do a search on your help for "local file attributes".

Review how to retrieve the "parentFile". This will give you just the path to the file. Then adjust accordingly...

Re: Relative Path

Posted: Mon Dec 05, 2016 11:30 am
by jchapman01
So I found the one example located here:

how-to-use-file-attributes-at-325

I copied that example out. However if I assign to a variable like

<variable name="File" value="resource:smb://SomeDirectory/SomeFile.txt" />
<variable name="FileDirectory" value="${ FileInfo( File):parentFile }" />

The output from ${ FileDirectory} is "${ FileInfo( File):parentFile }" and NOT "resource:smb://SomeDirectory".

Ideas?

Re: Relative Path

Posted: Mon Dec 05, 2016 11:44 am
by jchapman01
So I found the one example located here:

how-to-use-file-attributes-at-325

I copied that example out. However if I assign to a variable like

<variable name="File" value="resource:smb://SomeDirectory/SomeFile.txt" />
<variable name="FileDirectory" value="${ FileInfo( File):parentFile }" />

The output from ${ FileDirectory} is "${ FileInfo( File):parentFile }" and NOT "resource:smb://SomeDirectory".

Ideas?

Re: Relative Path

Posted: Mon Dec 05, 2016 12:06 pm
by jchapman01
So I found the "Set Variable" task and that worked. Apparently the example in the one post was not quite correct.

Re: Relative Path

Posted: Mon Dec 05, 2016 12:09 pm
by Support_Rick
The HELP text shows you 2 examples for the FileInfo Function:

Examples
${FileInfo("C:\example.txt"):exists} - Returns true or false indicating whether or not the file exists.
${FileInfo("resource:smb://resourceName/file.txt"):size} - Returns the file size of the specified file in a Network Shares resource.

Keep in mind that the parameter has to be a "STRING" value.

Try this:

<variable name="File" value="resource:smb://SomeDirectory/SomeFile.txt" />
<variable name="FileDirectory" value="${ FileInfo( String( File ) ):parentFile }" />