Simpel

[Solved]: @ScriptDir + space in parameter FileGetShortName not working

23 posts in this topic

#1 ·  Posted (edited)

Hi.

Local $sPDFtk = FileGetShortName(@ScriptDir & "\pdftk.exe")
Local $sInputPDF = FileGetShortName(@ScriptDir & "\Prodis_Test.pdf")
Local $sSig_1 = FileGetShortName(@ScriptDir & "\Sig_1.pdf")
Local $sTempPDF = FileGetShortName(@ScriptDir & "\Prodis_Test_TEMP.pdf")

$iSuccess = ShellExecuteWait($sPDFtk, $sInputPDF & " stamp " & $sSig_1 & " output " & $sTempPDF, "", "", @SW_HIDE)

@ScriptDir is "H:\_Conrad lokal\Downloads\AutoIt3\_COX". As you can see there is a space in the path.

I know that ShellExecuteWait is working with FileGetShortName at the filename. It seems to me that I can't pass the parameters that way. But without FileGetShortName it's not working too.

Ideas? Regards, Conrad

Edited by Simpel
SOLVED

Share this post


Link to post
Share on other sites



Does it work when you add quotes?

Local $sPDFtk = FileGetShortName("'" & @ScriptDir & "\pdftk.exe'")

 


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

No.

Share this post


Link to post
Share on other sites

Maybe relative path works:

Local $sPDFtk = FileGetShortName(".\pdftk.exe", 1)
Consolewrite("@Error: " & @Error & @CRLF)

 


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

For starters: So how did you determine that FileGetShortName() is not working?  what was the returned string?

Jos


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

What is the result when adding the following to the end of your code:

ConsoleWrite($sPDFtk & " " & $sInputPDF & " stamp " & $sSig_1 & " output " & $sTempPDF & @CRLF)

 

Share this post


Link to post
Share on other sites

The returned strings are:

@@ Debug(8) : $sPDFtk = H:\_Conrad lokal\Downloads\AutoIt3\_COX\AA\pdftk.exe
>Error code: 0
@@ Debug(10) : $sInputPDF = H:\_Conrad lokal\Downloads\AutoIt3\_COX\AA\Prodis_Test.pdf
>Error code: 0
@@ Debug(12) : $sSig_1 = H:\_Conrad lokal\Downloads\AutoIt3\_COX\AA\Sig_1.pdf
>Error code: 0
@@ Debug(15) : $sTempPDF = H:\_Conrad lokal\Downloads\AutoIt3\_COX\AA\Prodis_Test_TEMP.pdf
>Error code: 1

Share this post


Link to post
Share on other sites

If I do it this way:

RunWait($sPDFtk & " " & $sInputPDF & " stamp " & $sSig_1 & " output " & $sTempPDF, "", @SW_HIDE, $STDOUT_CHILD)

console says:

Error: expecting "output" keyword.  Instead, I got:
   lokal\Downloads\AutoIt3\_COX\AA\Sig_1.pdf
Errors encountered.  No output created.
Done.  Input errors, so no output created.

Share this post


Link to post
Share on other sites

#10 ·  Posted

No dir /x shows no shortnames. H: drive is my network homedrive.

Share this post


Link to post
Share on other sites

#11 ·  Posted

The help file for RunWait tells us: "Paths with spaces need to be enclosed in quotation marks."
So you need to enclose all paths in quotes:

RunWait("'" & $sPDFtk & "' '" & $sInputPDF & "' stamp '" & $sSig_1 & "' output '" & $sTempPDF & "'", "", @SW_HIDE, $STDOUT_CHILD)

 


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#12 ·  Posted

As all files except $sTempPDF return @error = 0 it is not a problem with FileGetShortName.
I assume $sTempPDF does not exist when you run PDFTk.

Unfortunately FileGetShortName needs the file to exist to get the proper short name. Please see the help file for details.
Why don't you use a short name like

Local $sTempPDF = @ScriptDir & "\TempPDF.pdf"

for the output file?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#13 ·  Posted

@water: relative path and enclose all paths in quotes for run did not work. Return is:

@@ Debug(23) : $iSuccess = 0
>Error code: 1

Share this post


Link to post
Share on other sites

#14 ·  Posted

@water: yes you're right $sTempPDF is made by the programm I want to execute. It's the output file. I even tested it with Local $sTempPDF = @ScriptDir & "\TempPDF.pdf" but the problem isn't the filename I guess but the path.

Share this post


Link to post
Share on other sites

#15 ·  Posted

I can't test at the moment but I think this could work:

Local $sPDFtk = FileGetShortName(@ScriptDir & "\pdftk.exe")
Local $sInputPDF = FileGetShortName(@ScriptDir & "\Prodis_Test.pdf")
Local $sSig_1 = FileGetShortName(@ScriptDir & "\Sig_1.pdf")
Local $sTempPDF = '"' & @ScriptDir & '\TempPDF.pdf"')

RunWait($sPDFtk & ' ' & $sInputPDF & ' stamp ' & $sSig_1 & ' output ' & $sTempPDF, '', @SW_HIDE, $STDOUT_CHILD)

 


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#16 ·  Posted (edited)

I had to delete ) at Local $sTempPDF to have proper syntax but anyway it's not working.

Edited by Simpel

Share this post


Link to post
Share on other sites

#18 ·  Posted

Puh,

Opt('ExpandVarStrings', 1) works. Now I have to be careful using $ or @ in messageboxes etc. Don't think I will need them here or will use $$ and @@.

Thank you all for your replies and help.

Regards, Conrad

Share this post


Link to post
Share on other sites

#19 ·  Posted

I don't believe Opt('ExpandVarStrings', 1) would be the fix, I just prefer to write vars in strings especially when I have to add lots of quotes for example this works for me as well:

Local $sPDFtk = @ScriptDir & "\pdftk.exe"
Local $sInputPDF = @ScriptDir & "\Prodis_Test.pdf"
Local $sSig_1 = @ScriptDir & "\Sig_1.pdf"
Local $sTempPDF = @ScriptDir & "\Prodis_Test_TEMP.pdf"

RunWait('"' & $sPDFtk & '" "' & $sInputPDF & '" stamp "' & $sSig_1 & '" output "' & $sTempPDF & '"', "", @SW_HIDE)

 

Share this post


Link to post
Share on other sites

#20 ·  Posted (edited)

This works too. So it is a question of where to put the right kind of quote at the right point. So this works too:

ShellExecuteWait($sPDFtk, '"' & $sInputPDF & '" stamp "' & $sSig_1 & '" output "' & $sTempPDF & '"', "", "", @SW_HIDE)

Thanks for replying this. So I could handle it that way I wanted. I hope I will keep that in mind. Quotes sometimes makes me crazy.

Edited by Simpel
Deleted one wrong sentence

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now

  • Similar Content

    • Mag91
      By Mag91
      Hey Community,
      cause im too new in the Auto it world i will try it with the your help. hopefully.
      I woud like to know how i can handle my Problem.
      ----
      I have a Excel Data with 362 random numbers.
      For Example:
      1166642335374 1172899897343
      .....
      this numbers are a part of the filepath ...example
      D:\Projekte\1166_64233_5374
      as u can see its the first number of the Excel data. After the first 4 numbers it shoud make a "_" than another 5 "_"
      This is my first question. How can i handle this to make it Shell execute.
       
      --------
      Second question:
      If i am in the path.
      For Example:
      D:\Projekte\1166_64233_5374
      the code shoud search for specific PDF Files.
      They are named like: 0050569E364B1ED79B900F73E62660EC.pdf
      the first 15 letters are always the same
      0050569E364B1ED
      when he found this data he has to copy it on a Folder on the Desktop.
      (There can also be 2 or 3 pdfs in one Folder with this letters)
      ----
      Please give me some help :-)
       
       
       
       
       
       
    • mihaijulien
      By mihaijulien
      Hello,
      I compiled a script I made that takes a command line parameter (the version of a .msi installer) when launched. The script was compiled with the /console option. The script (.au3) works fine but the executable returns  the following error:  
      Error: array variable has incorrect number of subscripts or subscript dimension range exceeded  
    • ur
      By ur
      I have a text file whose data will be as below.
      win10x64 ~\erwin Notallowed1! "erwin Data Modeler r9.7 (32-bit)_2500.exe" SilentInstall.exe win10x64clone1 ~\erwin Notallowed1! "erwin Data Modeler r9.7 (64-bit)_2500.exe" DM64.exe win10x64clone2 ~\erwin Notallowed1! "erwin Mart Server r9.7 (32-bit).exe" SilentInstall.exe win10x64clone3 ~\erwin Notallowed1! "erwin License Server r9.7 (32-bit).exe" SilentInstall.exe Each line will have multiple values separated by space.
      If a value contains space in it, the value is surrounded by quotes.
      My task is to check how many values are there in each line.
      If the line contains 5 values, I need to replace the 4th value with the string contained in a variable.
      If it contains 4 values then also  I need to replace the 4th value followed by appending 5 th value to it as SilentInstall.exe
      If the value I am replacing contains spaces then I need to surround the new value with quotes.
       
      Any one can suggest how to do this,??
    • AnonymousX
      By AnonymousX
      Hello,
      What command would I use to open the following folder directories for:
      Computer/This PC (windows 7/Windows 10)
      Libraries\documents
      Libraries\Pictures
      I know:
       Run("Explorer.exe " & $filepath) ShellExecute($filepath) can be used to open folder locations when you type in the full directory such as "C:\Users\%username%\Documents" but I'm trying to figure out how to use these windows short paths. 
      Thanks,
    • mond1106
      By mond1106
      how do I break the loop if my program is stuck in it without exiting the whole program?
       
      i just want it to start from the beginning of the code here is my program
       
      While 1
      $picture = "target.png"
      $result = _ImageSearch($picture,1,$x1,$y1,0,0)
      If $result = 1 Then
         Send("{4}")
         MouseClick("left",$x1,$y1,1,1)
         Sleep(2000)

         Do
         $picture2 = "status.png"
         $result2 = _ImageSearch($picture2,1,$x1,$y1,0,0)
         
         Send("{2}")
         Send("{1}")
      Until $result2 = 1
       
       
      as you see if my program doesnt detect  or see picture2 then the loop wont stop.