Parameter %1 is provided by doubleclicking on a file name in the directory C:\ESITOCHK an can be in the form:
"C:\ESITOCHK\xxxxxxxx.Nyy.PDF.P7M" or
"C:\ESITOCHK\xxxxxxxx.Xyy.P7M
I must create an output file (by program sbusta.bat) with the same name but without the P7M extension and:
if the first extension starts witx "N" i must create the corresponding xxxxxxxx.Nyy.PDF file
if the first extension starts witx "X" i must create the corresponding xxxxxxxx.Xyy file
This program works only if the parameter 1% is in the form "C:\ESITOCHK\xxxxxxxx.Nyy.PDF.P7M" and then
the variable "stringa" is "N";
The sbusta.bat wants two parameters: 1-input file path; 2-output file path
If "stringa" is "X", it seems that the sbusta.bat is not called since the output file is not in the output file path.
Can anyone explain to me why ? Please help me and thanks a lot in advance.
Paolo
@echo off
cls
set X=X
set N=N
set nomefile=%1
set fileinput=%nomefile%
set stringa=%nomefile%
set stringa=%stringa:~22,1%
set outpdf=%nomefile%
set outstd=%nomefile%
echo %fileinput%
set fileinput=%fileinput:~13,20%
set outpdf=%outpdf:~13,16%
set outstd=%outstd:~13,12%
echo fileinut %fileinput%
echo outpdf %outpdf%
echo outstd %outstd%
echo stringa %stringa%
pause
if %stringa% == X set outfile=%outstd%
if %stringa% == N set outfile=%outpdf%
echo outfile %outfile%
pause
call sbusta.bat %fileinput% c:\firmav~1\verifi~1\%outfile%
echo. End Program
pause
Help needed with string manipulation - PAOLO - Italy
Moderator: DosItHelp
-
- Posts: 2
- Joined: 17 Sep 2007 02:38
Paolo,
Try this one liner:
This is how it works:
if "%1" is "C:\ESITOCHK\xxxxxxxx.Nyy.PDF.P7M"
then:
"%~n1" will be "xxxxxxxx.Nyy.PDF"
"%~x1" will be ".P7M"
"%~nx1" will be "xxxxxxxx.Nyy.PDF.P7M"
"%~p1" will be "\ESITOCHK\"
"%~d1" will be "C:"
"%~dp1" will be "C:\ESITOCHK\"
"%~dpn1" will be "C:\ESITOCHK\xxxxxxxx.Nyy.PDF"
d is drive
p is path
n is name
x is extension
To get the filename without extension use "%~n1".
DOS IT HELP?
Try this one liner:
Code: Select all
call sbusta.bat "%1" "c:\firmav~1\verifi~1\%~n1"
This is how it works:
if "%1" is "C:\ESITOCHK\xxxxxxxx.Nyy.PDF.P7M"
then:
"%~n1" will be "xxxxxxxx.Nyy.PDF"
"%~x1" will be ".P7M"
"%~nx1" will be "xxxxxxxx.Nyy.PDF.P7M"
"%~p1" will be "\ESITOCHK\"
"%~d1" will be "C:"
"%~dp1" will be "C:\ESITOCHK\"
"%~dpn1" will be "C:\ESITOCHK\xxxxxxxx.Nyy.PDF"
d is drive
p is path
n is name
x is extension
To get the filename without extension use "%~n1".
DOS IT HELP?