Page 1 of 1

FilePath problems

PostPosted: Mon Sep 29, 2014 6:23 pm
by Leos
Hi,
I have a problem:
If i use the 'RUN' command with this file, i have no problems

Run "c:\test\mymusic.mp3"

But, with this file i got the message 'file not found'

Run "c:\te % st\mymusic.mp3"

I know that the problem is in the special character "%". I got the same problem using nom 'standart' characters, like '&' '#' and others...
Any easy solution, please?

Thank you

Re: FilePath problems

PostPosted: Mon Sep 29, 2014 8:22 pm
by Gaev
Leos:

Did you try ...
Code: Select all
Run "!c:\te % st\mymusic.mp3" "parameters" "options" "subroutine" "variable"

... i.e. with ! before the c:\te % st\mymusic.mp3

Re: FilePath problems

PostPosted: Tue Sep 30, 2014 3:38 am
by Leos
Hi Gaev,
In this case this solution "!" do not result.
I think that the solution is to replace the character '%' (and all the others non 'standard', like 'ã' , '&' , ...) by its code, but I'm not really an easy way to do it ...
best regards tu you.

.....
Your tip is useful in many cases; this is an example:

Run 'C:\1000+3\myfile.doc'

Re: FilePath problems

PostPosted: Tue Sep 30, 2014 5:03 am
by Gaev
Leos:

I think that the solution is to replace the character '%' (and all the others non 'standard', like 'ã' , '&' , ...) by its code, but I'm not really an easy way to do it ...

I tried this ...
Code: Select all
Run "C:\gk\te % st\abcd.txt" "" "Normal" "" ""

... and it opened the file under notepad.exe

The ascii code for % is 37 ... so I tried this ...
Code: Select all
Run "C:\gk\te [#37] st\abcd.txt" "" "Normal" "" ""

... and it also opened the file under notepad.exe

You might want to make sure that the folder name has exactly one space before and after the % sign.

Re: FilePath problems

PostPosted: Tue Sep 30, 2014 7:37 am
by Leos
it results with other characters...
May be the solution is a function to replace all the string ocurrency with non standart characters...

something like that:

StrReplace "[MyString]" "%" "[#37]" "[MyString]" ""
StrReplace "[MyString]" "_" "[#95]" "[MyString]" ""

...
Thank you

Re: FilePath problems

PostPosted: Wed Oct 01, 2014 12:13 pm
by Leos
I did the function but with the comma character "," do not works!!!
Stranger still:
This works, and open the text file:

RUN "C:\teste,2~2\file.txt"

This, do not works!!!
(it was supposed to open the folder)

RUN "C:\teste,2~2\"

Any solution, please?

Re: FilePath problems

PostPosted: Wed Oct 01, 2014 2:41 pm
by David de Argentina
Try to replace the LongFileName with the ShortFileName.

LongFileNames does not work in all cases.

My 0.01

David de Argentina

Re: FilePath problems

PostPosted: Wed Oct 01, 2014 3:55 pm
by Leos
Hi, David
In this case i don´t think that is the problem...

It just does'nt works with any folder with a 'comma' ',' in the folder's name...

Do you have any simple way to have the shortname? (I did it with 'Dir /x')

Thanks
Best regards to you

Re: FilePath problems

PostPosted: Wed Oct 01, 2014 8:31 pm
by David de Argentina
Save this as a VbScript function.

Code: Select all
publication.nbSetVar "[%2]", CreateObject("Scripting.FileSystemObject").GetFile("[%1]").ShortPath


Code: Select all
Parameters:

[%1] = Long FileName, text
[%2] = Return Var, variable


My (15x) devaluated cent,
David de Argentina

Re: FilePath problems

PostPosted: Thu Oct 02, 2014 7:19 am
by Leos
Hi, David

IT WORKS!!!

Thank you very mutch!!! :mrgreen:


My devalueted EuroCent!!!
(which is currently worse than yours :) )