Well, the thing is that the files i do want are folders, and not files with extensions. How do i identify Folders?
Re: Excluding Thumbs.db from Getfiles()
Re: Excluding Thumbs.db from Getfiles()
Well I don't think you should identify folders. Just recurse into all of them. You could easily set up an array of folders to ignore or folders to process however.
Re: Excluding Thumbs.db from Getfiles()
The script looks into the (Main) folder, and makes a list of all the sub-folders. Unfortunately, the (thumbs.db) file is always also a file inside the (Main) folder. The next thing that i do after getting the list of folder is identifying which was the latest edited one, and for some reason it always returns with the thumbs.db file, since it looks like windows updates this quite regularly.
Re: Excluding Thumbs.db from Getfiles()
I would find another way for "latest edited one". Get the date/time stamp on "latest file I care about"?
OR
How to Switch Off the Thumbs.db Image Cache File in Windows — SitePoint
Help - Way to filter files
Hi guys,
I have some photos in Bridge and with one script I take the exact image format sequence. Example: Horizontal, Vertical, Vertical, Vertical.
I have templates with windows sequences named like: vvvh, vvvv, hvvv, hvvvvvvvh, etc.....
How can I match the exact image sequence with my named files?
My Script take from Bridge the sequence: hvvv.
I want to show for user only templates with exact sequence.
Thanks,
Rei.
Start script if one layer is clicked
I trying to start one script only if have one layer clicked.
If dont have any layer clicked show one message.
I tried some ideas without success.
Help!
Thanks, Rei.
Re: Excluding Thumbs.db from Getfiles()
You are awesome thanks!
Re: Removing numbers from file names when exporting layers to files???
Line 2179 - fileNameBody += "";
Line 2181 - fileNameBody += "" + layerName;
Line 2215 - fileNameBody += "";
Re: Photoshop not visually updating while script is running?
I don't know if this will work, but you can try to set the script to step mode and back to accelerate mode with these two functions:
//function to refresh screen after each step function setActionToStep(){ var idsetd = charIDToTypeID( "setd" ); var desc1 = new ActionDescriptor(); var idnull = charIDToTypeID( "null" ); var ref1 = new ActionReference(); var idPrpr = charIDToTypeID( "Prpr" ); var idPbkO = charIDToTypeID( "PbkO" ); ref1.putProperty( idPrpr, idPbkO ); var idcapp = charIDToTypeID( "capp" ); var idOrdn = charIDToTypeID( "Ordn" ); var idTrgt = charIDToTypeID( "Trgt" ); ref1.putEnumerated( idcapp, idOrdn, idTrgt ); desc1.putReference( idnull, ref1 ); var idT = charIDToTypeID( "T " ); var desc2 = new ActionDescriptor(); var idperformance = stringIDToTypeID( "performance" ); var idperformance = stringIDToTypeID( "performance" ); var idstepByStep = stringIDToTypeID( "stepByStep" ); desc2.putEnumerated( idperformance, idperformance, idstepByStep ); var idPbkO = charIDToTypeID( "PbkO" ); desc1.putObject( idT, idPbkO, desc2 ); executeAction( idsetd, desc1, DialogModes.NO ); }//end function // function to return action to accelerated mode - no refresh of screen for each step.======================================================= function setActionToAcc(){ var idsetd = charIDToTypeID( "setd" ); var desc3 = new ActionDescriptor(); var idnull = charIDToTypeID( "null" ); var ref2 = new ActionReference(); var idPrpr = charIDToTypeID( "Prpr" ); var idPbkO = charIDToTypeID( "PbkO" ); ref2.putProperty( idPrpr, idPbkO ); var idcapp = charIDToTypeID( "capp" ); var idOrdn = charIDToTypeID( "Ordn" ); var idTrgt = charIDToTypeID( "Trgt" ); ref2.putEnumerated( idcapp, idOrdn, idTrgt ); desc3.putReference( idnull, ref2 ); var idT = charIDToTypeID( "T " ); var desc4 = new ActionDescriptor(); var idperformance = stringIDToTypeID( "performance" ); var idperformance = stringIDToTypeID( "performance" ); var idaccelerated = stringIDToTypeID( "accelerated" ); desc4.putEnumerated( idperformance, idperformance, idaccelerated ); var idPbkO = charIDToTypeID( "PbkO" ); desc3.putObject( idT, idPbkO, desc4 ); executeAction( idsetd, desc3, DialogModes.NO ); }//end function
Re: Script problem with pc
As pixxxel schubser mentioned, it's hard to know without know what it's doing or what the code is. However, you can get different results if your script doesn't set preferences for what you're doing, and it defaults to whatever that computer is set at. For example, if you have a script that adds lines of text using the DOM, if the leading has been altered on one computer, it will stay that way and mess up your line spacing with your script.
Re: Start script if one layer is clicked
Please explain the intended process more clearly.
Re: Help - Way to filter files
Give this one a shot.
This will return files that have specific name.
var pathToFolder = Folder.selectDialog("Select Folder"); // select a folder var recursion = true; // Process nested folder var namesToLookFor = "hvvv" // enter file name you need var myFiles = getSpecificFiles (pathToFolder, recursion, namesToLookFor) alert(myFiles.length) function getSpecificFiles(pathToFolder, recursion, namesToLookFor) { var pathFiles = Folder(pathToFolder).getFiles(), files = new Array(), subfiles; if (namesToLookFor === undefined) namesToLookFor = ""; else if (typeof namesToLookFor !== "function") namesToLookFor = new RegExp("\.\(" + namesToLookFor.replace(/,/g, "|").replace(/ /g, "") + ")", "i"); for (var i = 0, il = pathFiles.length; i < il; i++) { if (pathFiles[i] instanceof File) { if (pathFiles[i].name.match(namesToLookFor)) { files.push(pathFiles[i]); } } else if (pathFiles[i] instanceof Folder && recursion === true) { subfiles = getSpecificFiles(pathFiles[i], recursion, namesToLookFor); for (var j = 0, jl = subfiles.length; j < jl; j++) { files.push(subfiles[j]); } } } return files; }
Re: Start script if one layer is clicked
Are you working with ExtendScript or CEP panel?
It I am not mistaken ExtendScript cannot listen to DOM while CEP can.
So, in case you work with ExtendScript, you will have to determine if layer is selected by clicking somewhere in your ScriptUI.
Re: Start script if one layer is clicked
Script Events Manager would allow to run a Script at a certain event but I think I do not fully understand what the OP meant exactly.
It seems possible they simply meant a check in a Script that would determine to perform one thing if one Layer is selected and another if no Layer is selected.
Re: To create folder and move a specific number of files
Yes, It works perfectly.
Thanks again!
Tool Presets list not updating properly
Hi.
So I've run into a problem while trying to rename multiple tool presets.
It seems that when getting a list of tool presets, it does not get properly updated when using the method below.
As I use the list-getting method to also get indexes of for the tool presets, it screws up renaming multiple presets.
function cID (inVal) { return charIDToTypeID(inVal);} function sID (inVal) { return stringIDToTypeID(inVal);} renamePresetByIndex = function(index, name) { var ref = new ActionReference(); ref.putIndex(sID( "toolPreset" ), index); var desc = new ActionDescriptor(); desc.putReference(cID('null'), ref); desc.putString(cID('T '), name); executeAction(cID('Rnm '), desc, DialogModes.NO ); } getPresetList = function() { var ref = new ActionReference(); ref.putEnumerated( cID("capp"), cID("Ordn"), cID("Trgt") ); var appDesc = executeActionGet(ref); var List = appDesc.getList(stringIDToTypeID('presetManager')); var presetNames=[]; var list = List.getObjectValue(7).getList(cID('Nm ')); for (var i = 0; i < list.count; i++) { var str = list.getString(i); presetNames.push(str); } return presetNames; } alert("01: " + getPresetList()) renamePresetByIndex(1,"Moo_001") alert("02: " + getPresetList()) renamePresetByIndex(1,"Meep_001") alert("03: " + getPresetList())
Here is the output I get:
As you can see, the first renamed preset apparently remains at the first index, but it actually occupies the third index when the rename function is executed (as the Tool Presets list seems to generally self sort by name).
So my question is, am I doing something wrong?
Is there a better method for getting a correct name list and corresponding indexes?
Should I just get the list and sort it myself? (which adds the complexity of dealing with sorting by tool types... )
RePlace My Design In All Mockups SmartObjects
I HAVE 100 + MOCKUPS AND WANT TO CHANGE MY DESIGN IN ALL MOCKUPS I ADD DESIGN AND 2 MOCKUPS PLEASE HELP
1st mockup : 1+3 t.psd - Google Drive
2st mockup : Apple Iphone 6 6s.psd - Google Drive
Image : Black-Gold-Marbel-Unisex-Design.psd - Google Driv...
These are 2 mockups and one psd i have multiple mockup like this 100+ i want to do changes in all mockup with this image
Re: Embed multiple images based on condition?
Tomas and can make 2 changes to the script
The first change is to save the file in jpg
The second change is to select one Watemark and apply it to all selected photos.
Re: Embed multiple images based on condition?
You may be better off just having a simple script that will place and resize your watermark for the current document. With such a Script you could use in an action. The Acton could easily add a layer style to the placed watermark and even preposition it over the canvas. Once you have your custom action that could be batch using some like the Image Processor Pro plug-in you can download from the web. You could batch all your image files and save as many image file types you need that are the size you need all with your watermark correctly sized the image file.
This simple script will place in your watermark on your image bottom right corner. You need toe change the first vat to you png log file. You can optionally change the next two var to change the size of the logo and the corner margins.
#target photoshop; app.bringToFront(); var logoFile = "~/Desktop/JJMack.png"; // Watermark file should be large for resize down works better than up var LogoSize = 10; // percent of document height to resize Watermark to var LogoMargin = 1; // percent of Document height the Watermark should have as a margin placeWatermark(logoFile, LogoSize, LogoMargin); // Place Watermark into the bottom right of document function placeWatermark(Image,Size,Margin){ if(!documents.length) return; // if no document return try{ var doc = app.activeDocument; // set Doc object to active document app.displayDialogs = DialogModes.NO; // Dialog off var strtRulerUnits = app.preferences.rulerUnits; // Save Users ruler units var strtTypeUnits = app.preferences.typeUnits; // Save Users Type units app.preferences.rulerUnits = Units.PIXELS; // work with pixels app.preferences.typeUnits = TypeUnits.PIXELS; // work with pixels var fileObj = new File(Image); // the passed file if(!fileObj.exists){ // If file does not exits tell user alert(fileObj.name + " does not exist!"); return; } placeFile(fileObj); // Place in file the Watermark png file activeDocument.activeLayer.resize(100 ,100,AnchorPosition.MIDDLECENTER); // Insure Place did not scale layer var SB = activeDocument.activeLayer.bounds; // get layers bounds var layerHeight = SB[3] - SB[1]; // get layers height var resizePercent = (100/layerHeight)*(Size/100*doc.height.value); // Percent to resize by activeDocument.activeLayer.resize(resizePercent ,resizePercent,AnchorPosition.MIDDLECENTER); // Resize width and height by percentage SB = activeDocument.activeLayer.bounds; // get resized layers bounds activeDocument.activeLayer.translate(-SB[0].value,-SB[1].value); // Move resized layer to top left canvas corner var LayerWidth = (SB[2].value - SB[0].value); var LayerHeight = (SB[3].value - SB[1].value); marginSize = Margin/100*doc.height.value; // move resized watermark into the document lower right corner with some margin activeDocument.activeLayer.translate((doc.width.value -marginSize - LayerWidth),( doc.height.value -marginSize - LayerHeight)); } catch(e) { alert(e + ': on line ' + e.line); } // inform user of error finally{ app.preferences.rulerUnits = strtRulerUnits; // Restore user ruler units app.preferences.typeUnits = strtTypeUnits; // Restore user type units }; }; function placeFile(placeFile) { var desc21 = new ActionDescriptor(); desc21.putPath( charIDToTypeID('null'), new File(placeFile) ); desc21.putEnumerated( charIDToTypeID('FTcs'), charIDToTypeID('QCSt'), charIDToTypeID('Qcsa') ); var desc22 = new ActionDescriptor(); desc22.putUnitDouble( charIDToTypeID('Hrzn'), charIDToTypeID('#Pxl'), 0.000000 ); desc22.putUnitDouble( charIDToTypeID('Vrtc'), charIDToTypeID('#Pxl'), 0.000000 ); desc21.putObject( charIDToTypeID('Ofst'), charIDToTypeID('Ofst'), desc22 ); executeAction( charIDToTypeID('Plc '), desc21, DialogModes.NO ); };
Re: Start script if one layer is clicked
Hi Tomas, I´m working in a CEP panel.
Thanks for your help.