Skip to main content
Pedro Cortez Marques
Legend
May 24, 2013
Question

Can't read big name of folders by script

  • May 24, 2013
  • 1 reply
  • 781 views

It happens once in a while that the images we had edit and are ready to save give us an error saying that the File I want to saveAs can't be found.

So, in this case, we had to save manually each image, rename the folder to a shorter name mannually, re-open the images and apply the script again.

This solve the problem.

To avoid this, or at least to warn automatically that some encoded folderName.length is too big.

I HAVE FOUND THAT ON WINDOWS7 THE ERROR BEGINS ON FOLDERS LENGTH >188

I had the ideia of making a 'thumbsPreview' event on Bridge where a big folder warning would be generated so I could add a button on bridge where automatically we rename that folder to only the first 188 caracters. But this is for Bridge forum. I leave here only the idea.

PROBLEM:

So, on photoshop, reading a folder name larger then 188 caracter encoded name by script, give us a shorter version of the real name.

This is an real example:

Real big folder name of an active image ( encoded length = 211):

_d_10416472-ACNE.ASKIN.DARK.BROWN.COGNAC.Calf.Leather.BASICON.BS08ANCORA.COCCIO.Cotton.Spandex.Elastane.Calf.Leather.Calsssf.Leather.FS0526G8WF0EQW.F0EQW.Cotton.SW.Cotton.Spandex.Elastane.Cotton.Spandex.Elastane

Name red by script ( encoded length = 12):

_D_104~1.LEA

Resume:

So, the result is an error on saving the file to a folder that doesn't exist ('_D_104~1.LEA').

The problem is that if I cant read it, I can't rename it by script to force it to rename to 188 length.

I have to use bridge and do it mannually

Middle prevent sollution:

Anyway of detecting that a folder name has been shortened by script so I could use that to make an specific alert???

I have tryed by I couldn't.

Curiosity:

By script I can easly create() new folders larger then 188 length name! But then I can't use them - not even to put files in (error)...

This topic has been closed for replies.

1 reply

Inspiring
May 24, 2013

It's an OS/file system issue that has be around for a long time. And it's not just a folder name length limit. It's the length of the entire file path. Which is why you can create a long named folder but can't save files to it( unless they have very short filenames so the total path length is < 255 ).

Pedro Cortez Marques
Legend
May 25, 2013

Thanks Michael

So that means I can't have too much folder/subFolder/subFolder/... organization.

I was trying to detect when a path is larger then 255, at the moment I try to saveAs. To do so, I have put a try catch when execute the action and on the error code I manage to do this:

- read the name truncated of the last folder on the path (it is, in my case, allways the larger one);

- I don't know if I could trust on this: if the end of the truncated name is == ".LEA" then i means that the folder must be shortened and give the user that precise information.

Can I trust this?

Inspiring
May 25, 2013

I am not clear about if you are using an action or a script.

If you are using a script I think it would be much better to check the length of the file object's fsName property before the saveAs step rather than trying to catch an error or do a string test for a truncated name afterwards.