Koba has asked for the wisdom of the Perl Monks concerning the following question:

G'day monks,

i need your wisdom for i tricky problem.

I am running on a WINDOWS server through a UNC path with a by find2perl created script. But as soon as it reaches the first folder with more than 256 chars folder length it terminates with an error.

Now i think the easiest way is to use short file/foldernames. But how can i tell perl to use short names for my script?

Or is there any other way to solve this problem. I cannot run it on the device itself, it's a NAS. And to assign the unc path to a drive letter needs an exception request which will cost me days of paperwork.

Replies are listed 'Best First'.
Re: find2perl and 256 chars folder length
by BrowserUk (Patriarch) on Mar 14, 2010 at 12:01 UTC

    Take a look at the (Windows) subst command. Itr allows you to locally assign a drive letter to any path.

    This can also be done programmincally using Win32::FileOp::subst().


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.
Re: find2perl and 256 chars folder length
by afoken (Chancellor) on Mar 14, 2010 at 15:38 UTC
      But this is exactly what my problem is. I need a way to tell the perl interpreter to use only short names. Or i have to rewrite the find module to convert each file/folder into short named version before searching the next subfolder. Anyone any idea?

        One option would be to use windows tools instead to get your list of files. Eg.

        c:\test>dir /s /b Zz* c:\test\ZZXYZ c:\test\abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghij +klmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyza +bcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqr +stuvwxyzabcdefghijklmnopqrstuvwxyz\ZZZXYX

        You can either pipe the list into your script, or invoke the command via a piped open and get it that way.


        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        "Science is about questioning the status quo. Questioning authority".
        In the absence of evidence, opinion is indistinguishable from prejudice.

        Download the source from my page, find the functions I used, and use Win32::API or one of the existing Win32 functions to port my algorithm to perl. Win32::GetShortPathName() and Win32::GetLongPathName() are documented in the latter module, but they are availabe as CORE functions (without use Win32;), so you don't even have to mess with Win32::API.

        Alexander

        --
        Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)
Re: find2perl and 256 chars folder length
by Anonymous Monk on Mar 14, 2010 at 12:01 UTC
    Try Win32::GetShortPathName()