Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Executing long Directory Command in DOS
Message
From
17/12/2013 11:41:55
 
 
To
16/12/2013 12:10:39
General information
Forum:
Visual FoxPro
Category:
Troubleshooting
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows XP SP2
Network:
Windows XP
Database:
Visual FoxPro
Application:
Desktop
Miscellaneous
Thread ID:
01590257
Message ID:
01590495
Views:
53
The file has to already exist before getting its short filename will work.

In your use case I would suggest creating a temporary directory and using a short filename for the initial generation, and then moving the file afterward with something like:
lcDir = "c:\mytemp\"
MD &lcDir
lcPdf = lcDir + sys(2015) + ".pdf"
lcPs  = FORCEEXT(lcPdf, "ps")

* Run it
!gswin32c.exe -sDEVICE="pdfwrite" -sPAPERSIZE=a4 -dNOPAUSE -dBATCH -dSAFER -dQUIET -sOUTPUTFILE=&lcPdf &lcPs

* Move both files
lcPdf = lcDir + JUSTSTEM(lcPdf)
!MOVE &lcPdf..p* "D:\COMP JAIPUR\20131106_20131101\100042\1005753165.*"
Several ways to address this. You might be able to fix it by using -sOUTPUTFILE="file" with quotes around your lengthy filename.


>I tried it
>
>Call with:
> lcShortFilename = getShortFilename('D:\COMP JAIPUR\20131106_20131101\100042\1005753165.Pdf')
>     ? "Short filename: " + lcShortFilename
>
>And also
> lcShortFilename = getShortFilename('D:\COMP JAIPUR\20131106_20131101\100042\1005753165.Pdf'@llIsValid)
>     ? "Short filename: " + lcShortFilename
>
>
>
>But got errors. Please Explain the usage with Example in my case
>
>Thanks
>
>
>>>The command inside is
>>
gswin32c.exe -sDEVICE="pdfwrite" -sPAPERSIZE=a4 -dNOPAUSE -dBATCH -dSAFER -dQUIET -sOUTPUTFILE=D:\COMP JAIPUR\20131106_20131101\100042\1001817119.Pdf D:\COMP JAIPUR\20131106_20131101\100042\1001817119.ps
>>
>>Generate the output files to some temporary location, and then rename them afterward. Use this to get the short filename:
>>
>>
* Call with:
>>* lcShortFilename = getShortFilename(lcLongFilename, @llIsValid
>>* IF llIsValid
>>*     ? "Short filename: " + lcShortFilename
>>* ELSE
>>*     ? "Unable to determine short filename from: " + lcLongFilename
>>* ENDIF
>>FUNCTION getShortFilename
>>PARAMETERS pcLongFilename, plValid
>>LOCAL lcShortFilename, lnShortFilenameLength, lnReturnValue
>>
>>    #DEFINE MAX_PATH 255
>>    DECLARE INTEGER GetShortPathName IN Kernel32 STRING @lpszLongPath, STRING @lpszShortPath, INTEGER cchBuffer
>>    DECLARE INTEGER GetLastError IN Win32api
>>
>>    IF EMPTY(pcLongFilename)
>>        pcLongFilename = FULLPATH(CURDIR())
>>    ENDIF
>>
>>    * buffer to receive converted file name
>>    lcShortFilename         = SPACE(MAX_PATH)
>>    lnShortFilenameLength   = LEN(lcShortFilename)
>>
>>    * if successful, lnReturnValue will contain the length of the output string
>>    lnReturnValue = GetShortPathName(@pcLongFilename, @lcShortFilename, lnShortFilenameLength)
>>    IF lnReturnValue = 0
>>        plValid = .F.
>>        RETURN "?? Unable to get the short path"
>>    ENDIF
>>    plValid = .T.
>>
>>    * truncate it at the length the return value indicates
>>    RETURN LEFT(lcShortFilename, lnReturnValue)
>>
>>
>>
>>>My problem is that the input and output path being Long folder names as (perhaps more than 8 character)
>>>the process dont work.When I change the folder name to small one it works fine.
>>>
>>>But manually it is not possible to change name of thousnds of such folder.
>>>
>>>What is to be done. Any alternative ?
>>>
>>>Also one more related issue. The above conversion process is taking huge time , I am working on 32 Bit windows XP.
>>>Will my Migration to 64 Bit Win-7 and 8 will enhance my above speed of conversion.
>>>If yes, than how much time(if any Idea)
>>>
>>>Kinldy Guide
>>>Regards
Previous
Reply
Map
View

Click here to load this message in the networking platform