Skip to main content
Known Participant
February 10, 2023
Answered

'Fit to Screen' script shuffling file sequence

  • February 10, 2023
  • 5 replies
  • 3120 views

Only replies from Mac users/experts please:

 

I use a Macbook Pro 14" running the latest OS 13.1 and have an issue with a Photoshop script I created to automatically make large batches of images 'Fit to Screen' (command + 0) when opening. The script does what it's supposed to and upon opening large batches of photos from the RAW window into Photoshop, it flies through them all and resizes them to fit the window, but it shuffles them out of sequence which really messes with my workflow. I need them to open sequentially by filename as they normally would. Any ideas how I can fix the issue?

This topic has been closed for replies.
Correct answer Stephen Marsh

The following script will cycle over all open docs and fit to screen. Although It can be set to run via the Script Events Manager using the Open event, this would repeat the script for each document opened (the script is fast, but it seems pointless using this via the Open event). I have tested using a small batch of Raw files from ACR with prefs set to open as floating windows and the initial sort order is maintained.

 

/*
https://community.adobe.com/t5/photoshop-ecosystem-discussions/fit-to-screen-script-shuffling-file-sequence/m-p/13570962
v1.0, 11th February 2023, Stephen Marsh
*/

#target photoshop

if (app.documents.length) {

    for (var i = 0; i < app.documents.length; i++) {
        app.activeDocument = app.documents[i];
        fitOnScreen();
    }

} else {
    alert('You must have a document open!');
}

function fitOnScreen() {
    var idselect = stringIDToTypeID("select");
    var desc1394 = new ActionDescriptor();
    var idnull = stringIDToTypeID("null");
    var ref710 = new ActionReference();
    var idmenuItemClass = stringIDToTypeID("menuItemClass");
    var idmenuItemType = stringIDToTypeID("menuItemType");
    var idfitOnScreen = stringIDToTypeID("fitOnScreen");
    ref710.putEnumerated(idmenuItemClass, idmenuItemType, idfitOnScreen);
    desc1394.putReference(idnull, ref710);
    executeAction(idselect, desc1394, DialogModes.NO);
}

 

https://prepression.blogspot.com/2017/11/downloading-and-installing-adobe-scripts.html

 

5 replies

Stephen Marsh
Stephen MarshCorrect answer
Community Expert
February 11, 2023

The following script will cycle over all open docs and fit to screen. Although It can be set to run via the Script Events Manager using the Open event, this would repeat the script for each document opened (the script is fast, but it seems pointless using this via the Open event). I have tested using a small batch of Raw files from ACR with prefs set to open as floating windows and the initial sort order is maintained.

 

/*
https://community.adobe.com/t5/photoshop-ecosystem-discussions/fit-to-screen-script-shuffling-file-sequence/m-p/13570962
v1.0, 11th February 2023, Stephen Marsh
*/

#target photoshop

if (app.documents.length) {

    for (var i = 0; i < app.documents.length; i++) {
        app.activeDocument = app.documents[i];
        fitOnScreen();
    }

} else {
    alert('You must have a document open!');
}

function fitOnScreen() {
    var idselect = stringIDToTypeID("select");
    var desc1394 = new ActionDescriptor();
    var idnull = stringIDToTypeID("null");
    var ref710 = new ActionReference();
    var idmenuItemClass = stringIDToTypeID("menuItemClass");
    var idmenuItemType = stringIDToTypeID("menuItemType");
    var idfitOnScreen = stringIDToTypeID("fitOnScreen");
    ref710.putEnumerated(idmenuItemClass, idmenuItemType, idfitOnScreen);
    desc1394.putReference(idnull, ref710);
    executeAction(idselect, desc1394, DialogModes.NO);
}

 

https://prepression.blogspot.com/2017/11/downloading-and-installing-adobe-scripts.html

 

Stephen Marsh
Community Expert
February 11, 2023

@hagenh32128020 wrote:

As I've said a bunch of times in these posts, this was never an issue with past versions of Photoshop, only since a recent update changed the way files open right across the screen instead of staying within the blank part of the workspace. It has nothing to do with anything you've mentioned above.


 

OK, I'd like to push the reset button on this discussion...

 

Disable the Script Events Manager step that fits the image to the screen when opening.

 

Now what happens when you open a large batch of images as floating windows?

 

I'm trying to understand if the behaviour you note is related the the SEM+Action or if this just how things are for your version of Photoshop and the OS. I'm on a 15" MacBook Pro but on OS12, so I don't know if this is a Ventura issue or not.

Known Participant
February 12, 2023

Thanks for the response, it's refreshing to have a coherent response from someone who obviously took the time to understand my problem and what I'm trying to acheive.

 

1/ The initial problem with the floating windows opening over the top of my palettes happens regardless of whether the Script Events Manager step is diabled or not. This never used to happen with my older versions of Photoshop - all of the files used to automatically open only within the bounds of the blank workspace.

 

2/ The sole reason for me using the Script Events Manager+Action is to fix the issue above, and although it works well to get all the files back inside the blank workspace, it creates the second issue of shuffling all of my files out of order. 

 

Both issues were happening when I was running OS12 and have persisted since updating to OS13 so it doesn't appear to be a Ventura issue. Hopefully that clarifies everything.

Stephen Marsh
Community Expert
February 13, 2023

OK, I'm curious if the script retains the document open order? It did for me... That being said, it sounds like the floating document windows overlapping the panels is a recent programming change that is outside of scripting.

Brainiac
February 10, 2023

So I'm not sure I understand the issue here. Are you saying that the script reorganizes your windows while resizing them? You'll have to deal with that in the script itself, you can get all open documents, parse the filenames, and arrange them in sequence.

I have a script that maximizes a document window and it doesn't have this issue on either Mac or Windows so I'm not sure what you are doing. As requested, please post your script so we can look at it.

Known Participant
February 10, 2023

As I mentioned above, the only reason I'm having to go through this process is as follows: I never used to have to use a 'Fit to Screen' script/action until a typical Photoshop update somehow messed with my usual workflow process and started opening images over the top of my action/history/layers windows etc. on the right hand side of my screen which means I couldn't see/use those menus until all the photos were removed from obscuring them. Super annoying. Is there any other way (aside from using a script/action) of making sure large batches of files stay inside the the bounds of the blank space when opening?

 

The issue you've outlined in your response is correct - as the script/action is applied to the images to fix the issue I just outlined, it shuffles the images out of sequence, so when I start editing them they are all out of chronological order. Before this problem started, if I was to open 100 images as a batch in Photoshop without the scrip/action, they would all stay in chronological order.

 

Sorry if I've used the wrong terminology, I'm no expert when it comes to using the Script Events Manager. Here is a link to exactly what I did - https://asktimgrey.com/2018/05/25/always-fit-on-screen/

Known Participant
February 10, 2023

I see this happen with a large number of document windows and a smallish screen area. Photoshop runs out of room to tile photos. You might be able to fix this with use of the Arrange submenu, or may try the tab key to hide and show palettes.


Yes, that's quite obvious but Photoshop should just stack the images on top of each other like it does for most of them anyway - what's the point of having some of them overflow on top of the palettes??? Photoshop never used to do this, it would only open images inside the bounds of usable blank workspace which made perfect sense.

 

The tab key to hide and show palettes doesn't work and I've already tried all the options I can think of in the arrange menu, none of which solve the problem.

Stephen Marsh
Community Expert
February 10, 2023

Are you using  the Script Events Manager to automatically run the script?

 

It might help if you posted the script code.

 

Known Participant
February 10, 2023

Thanks, are you able to tell me where I can find the script code please?

Stephen Marsh
Community Expert
February 10, 2023

No idea, it's your script? Is it found in the File > Scripts menu? If so, it is in the Presets/Scripts folder in the Photoshop application folder.

 

Do you really mean (Java)Script, or perhaps you actually mean an Action?

 

How is the automation performed?

Known Participant
February 10, 2023

Actually one thing to note - I never used to have to use a script until a typical Photoshop update somehow messed with my usual workflow process and started opening images over the top of my action/history/layers windows etc. on the right hand side of my screen which means I couldn't see/use those menus until all the photos were removed from obscuring them. Super annoying. Is there any other way (aside from the script mentioned above) of making sure large batches of files stay inside the the bounds of the blank space when opening?

Known Participant
February 10, 2023

I also use individual floating windows for each photo and want to keep working that way as opposed to using tabs/tiles for each image - just to avoid anyone suggesting that as a solution. Thanks