Jump to content











Photo
- - - - -

How to sepatate a filename from path


  • Please log in to reply
6 replies to this topic

#1 pedrole15

pedrole15

    Silver Member

  • .script developer
  • 731 posts
  •  
    France

Posted 03 October 2006 - 09:56 PM

In Winbuilder I select a filename by the FileBox so I have %pFileBox1%=C:\Source\Apps\prog.exe
I want to extract prog.exe from %pFileBox1% to %progname%=prog.exe and %progfolder%=Apps
How to do this ?

#2 Nuno Brito

Nuno Brito

    Platinum Member

  • Team Reboot
  • 10,122 posts
  • Location:boot.wim
  • Interests:I'm just a quiet simple person with a very quiet simple life living one day at a time..
  •  
    European Union

Posted 03 October 2006 - 10:03 PM

A new option can be added on the command strformat to extract both values (path and file) into a separate variable.. :P


Something like:

StrFormat,file,%pFileBox1%,%myFile%

Where %myFile% will hold the value "prog.exe"

Or:

StrFormat,path,%pFileBox1%,%myPath%

Where %myPath% will hold the value "Apps"


Would this be enough? :P

#3 Alexei

Alexei

    Silver Member

  • .script developer
  • 664 posts

Posted 03 October 2006 - 11:08 PM

In Winbuilder I select a filename by the FileBox so I have %pFileBox1%=C:\Source\Apps\prog.exe
I want to extract prog.exe from %pFileBox1% to %progname%=prog.exe and %progfolder%=Apps
How to do this ?

If you need it ASAP you can get it with cmd.exe using %~nx :P
Run for /? from cmd prompt for more info.
:P
Alexei

#4 pedrole15

pedrole15

    Silver Member

  • .script developer
  • 731 posts
  •  
    France

Posted 05 October 2006 - 02:01 PM

If you need it ASAP you can get it with cmd.exe using %~nx :P
Run for /? from cmd prompt for more info.
:P
Alexei

Thank you Alexei and Nuno :P
I am :P for extract the prog.exe
But for the second :P
With %~dpI i have "C:\Source\Apps\" I want to have "C:\Source\Apps"
Or is there a command to delete the last character from a %Var% ?

StrFormat,file,%pFileBox1%,%myFile%
StrFormat,path,%pFileBox1%,%myPath%
Nuno , This would be :P

#5 pscEx

pscEx

    Platinum Member

  • Team Reboot
  • 12,309 posts
  • Location:Korschenbroich, Germany
  • Interests:What somebody else cannot do.
  •  
    European Union

Posted 05 October 2006 - 02:30 PM

A new option can be added on the command strformat to extract both values (path and file) into a separate variable.. :P
Something like:

StrFormat,file,%pFileBox1%,%myFile%

Where %myFile% will hold the value "prog.exe"

Or:

StrFormat,path,%pFileBox1%,%myPath%

Where %myPath% will hold the value "Apps"
Would this be enough? :P


Would be nice to have also:
root (e.g. 'prog') and extention (e.g. 'exe')

Peter

#6 Alexei

Alexei

    Silver Member

  • .script developer
  • 664 posts

Posted 11 October 2006 - 03:42 PM

With %~dpI i have "C:\Source\Apps\" I want to have "C:\Source\Apps"
Or is there a command to delete the last character from a %Var% ?

Yes, there is.
Found in my old batch. This deletes first and last characters:
call set newval=%%newval:^~1,-1%%
At least you know what to look for :P
:P
Alexei

#7 Nuno Brito

Nuno Brito

    Platinum Member

  • Team Reboot
  • 10,122 posts
  • Location:boot.wim
  • Interests:I'm just a quiet simple person with a very quiet simple life living one day at a time..
  •  
    European Union

Posted 11 October 2006 - 07:15 PM

Yes, there is.
Found in my old batch. This deletes first and last characters:

call set newval=%%newval:^~1,-1%%
At least you know what to look for :P
:P
Alexei


This is a new one for me.. Nice code Alexei! :P

Perhaps a command to handle strings might help too, in the meanwhile I've already coded the path/filename/extension options in strformat - will be available on next beta.. :P




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users