The analysis of a script file name

Hello

I am now taking the name of image file and analyzed so that I only get the number of poses to the left. For example: the name of the file is Jones12345_002.jpg. I want only the file name 002 part. I have watched the addfilename scripts but have not found anything that will separate the name.

I tried this code, but it seems to ignore the analysis code, I added:

startup code

This script is a variant of the script addTimeStamp.js, which is installed with PH7

If (documents.length > 0)
{
var originalRulerUnits = preferences.rulerUnits;
preferences.rulerUnits = Units.PIXELS;

Try
{
var docRef = activeDocument;

Now create a layer of text on the front
var myLayerRef = docRef.artLayers.add ();
myLayerRef.kind = LayerKind.TEXT;
myLayerRef.name = "Filename";

var myTextRef = myLayerRef.textItem;

Strip extension
var fileNameNoExtension = docRef.name;
fileNameNoExtension = fileNameNoExtension.split (".");
If (fileNameNoExtension.length > 1) {}
-fileNameNoExtension.length;
}
fileNameNoExtension = fileNameNoExtension.join(".");

myTextRef.contents = fileNameNoExtension;

test cut filename to last 3 characters

sFileName var = "";
yStr = myTextRef.contents;
function getFname (yStr) {}

for (= yStr.length - 1; nloop nloop > 1; nloop-) {}
If (yStr.charAt (nloop) == '_') {}
sFileName = yStr.substring (nloop + 1, yStr.length);
break;
}
}
return sFileName;

}
myTextRef.contents = sFileName;

finish cutting filename to last 3 characters


Set the text to be in the Middle
myTextRef.position = new Array (docRef.width / 2, docRef.height / 2);
myTextRef.size = 20;
}
catch (e)
{
An error has occurred. Restore units of the rule, and then spread the error return
to the user
preferences.rulerUnits = originalRulerUnits;
throw e;
}

Everything went well. Restore units of the rule
preferences.rulerUnits = originalRulerUnits;
}
on the other
{
Alert ("you must have a document open to add the file name! ');
}

end of the code

Thanks for any help

Here's your code with the change...

if ( documents.length > 0 )
{
var originalRulerUnits = preferences.rulerUnits;
preferences.rulerUnits = Units.PIXELS;
try
{
  var docRef = activeDocument;
  // Now create a text layer at the front
  var myLayerRef = docRef.artLayers.add();
  myLayerRef.kind = LayerKind.TEXT;
  myLayerRef.name = "Filename";

  var myTextRef = myLayerRef.textItem;

  // strip the extension off
var Name =  decodeURI(docRef.name).replace(/\.[^\.]+$/, '');
var fileNameNoExtension = Name.match(/\d+$/).toString();
myTextRef.contents = fileNameNoExtension;
  // off set the text to be in the middle
  myTextRef.position = new Array( docRef.width / 2, docRef.height / 2 );
  myTextRef.size = 20;
}
catch( e )
{
  // An error occurred. Restore ruler units, then propagate the error back
  // to the user
  preferences.rulerUnits = originalRulerUnits;
  throw e;
}
// Everything went Ok. Restore ruler units
preferences.rulerUnits = originalRulerUnits;
}
else
{
alert( "You must have a document open to add the filename!" );
}

//end code

Tags: Photoshop

Similar Questions

  • The unsaved changes in queue: [File name] save before closing?

    Hello!

    FM 9 on Win 7 Pro.

    I'm a long-time user of FM.

    I am trying to open the files I could successfully open before I left work yesterday. I can open FM and open the books of FM. When I try to open an FM in a book, or an FM file not in a book, I get this message:

    "The unsaved changes in queue: [File name] save before closing? No Yes No Cancel.

    It doesn't matter which choose (Yes, no, cancel), following FM shows this message:

    FrameMaker 9 Application has stopped working. Windows can check online for a solution to the problem.

    Search online for a solution and close the program

    Close the program.

    Details of problem

    It doesn't matter what file I try to open (recently worked on the files and I have not touched it since some time). Same messages, anything.

    I tried to update the book (the update seems to happen), save the changes and then try to open. Same error messages. I had hoped that updating the book would clearly any possible referral.

    I tried several reboots, nothing works.

    Help!

    Thanks in advance for any help!

    Terri

    Since his happens with all files, my suspicion is that your application data are damaged. Try this:

    1. close FrameMaker.
    2. Delete the following directory: C:\Users\[user]\AppData\Roaming\Adobe\FrameMaker\
    3. reopening of framemaker and see if the problem is reproducible.
  • Read the character 3 + 4 of file name and move it to another position

    Hello

    I need a JavaScript to read the name of my file (I have one for the full filename) and especially the 3rd and 4th position of the file name.

    The characters on the position 3 and 4 must be moved to the position just before the extension.

    Example:

    4 pIN12345.pdf (old name) should be 4 P 12345_en.pdf

    Now, I have the following script to extract all pages in an existing pdf file to separate pages with the suffix still before the extension

    / * Extract Pages to the file * /.

    var re = /. * \/|\.pdf$/ig;
    var filename = this.path.replace(re,"");

    {
    for (var i = 0;  I < this.numPages;. i++ )
    this.extractPages

    ({
    Start: I,.
    nEnd: I,.
    cPath: filename + "_page_" + (i + 1) + "3_en.pdf".
    });
    };

    Can someone help me to put me on the right track?

    It is not related to Scripture, it has to do with the output parameters of the Action...

  • How to set property of the command shell (batch) script file comment?

    How a shell script (file "beats") adjustable the comment of a file?

    Hello

    The question you posted would be better suited in the TechNet Forums. I would recommend posting your query in the TechNet Forums:

    https://social.technet.Microsoft.com/forums/scriptcenter/en-us/home?Forum=iTCG

  • Try to copy the corrupted user profile profile settings and I am met with the error message "too long file name!

    I tried to connect to my laptop today and instead of recording in the usual way a message that windows creates new office settings. When he finally connects me I get a message of bubble speech saying I was connected to a temporary profile, I reboot several times and the problem persists. After a little google research, I realize my old profile is probably corrupted... I have not downloaded a new software/hardware.

    I followed the steps of miscrosoft to copy the files from my old profile to a new user, everything in the file transfer went well until the last few files to copy. Then, I get this error message saying "the file names would be too long for the destination folder", only two options are cancel and skip available. Which are useful.

    I do not recognize these folders that are too long (the names are the random letters and numbers), I tried to look for them, nothing is done. And to be honest, I don't understand what that means.

    UPDATE: I decided to copy folder a bit at a time and it solved my problem, that all the files were copied successfully. However, now I was struck with a new problem. Whenever I try to access my files, I get a message that says windows cannot access the specified device, path or file. You may not be authorized appropriate. How can I fix it?


    It comes to my laptop and I administer it / have access to passwords, etc.

    It simply means that your old account was the owner of that file or folder.  You can change the security to access your new account.  Here are the instructions: http://windows.microsoft.com/en-PK/windows-vista/Troubleshoot-access-denied-when-opening-files-or-folders

    (It says Vista, but the steps are the same for 7).
  • What would be the Windows 7 Installer download file name?

    A couple of years ago, I bought Windows 7 to upgrade a Vista laptop.  It is a download purchase that I had to create an installation DVD of.  Long story short, I never put Windows 7 on the laptop.  I did the installation DVD is not found I want to update now.  Somewhere on my computer laptop is that file that I downloaded to create the Windows Installer DVD... but what the hell would be the name of the file?  I have my product code recorded in the receipt of e-mail from the purchase of Windows, but of course the download link for the file is now expired.  I can order a backup drive now that the download link has expired, but I prefer to find the file and do not have to wait for a disk to be shipped.

    Any help to know which files am I looking for?  I'm guessing that maybe it's a zip file?  My hard drive is full and I have no idea what file name, I should be looking.

    Thanks for any help.

    Hello!

    You may search for *.iso in Windows Explorer on the desktop.

    In the case where you can't find it you can download it here: http://www.w7forums.com/official-windows-7-sp1-iso-image-downloads-t12325.html

    Concerning
    Julia

  • How can I sort my photos to the Organizer in order of file name?

    How can I sort my photos in 'Order of file name' to the Organizer?

    Do you use items 11?

    This is the only version do not support sort order of file name.

  • get the node of SQL query file name

    Hi all
    I have a concurrent request that requires the name of file as input. For example, when I connect to oracle on our test instance, I use http://moon1.oando-plc.com:8000. For this program at the same time, the node file name appears as moon1.oando - plc.com.
    I need to use this argument to a PL/SQL procedure, that I write and I don't want to use any hard coding.
    Is it possible to get this data into an SQL statement.

    Thank you

    Hello

    You can get table ICX_PARAMETERS (HOME_URL column). Orsearch profile options values for 'http' get the login page URL (or server name) - see (Note: 201945.1 - How E-Business Suite profile Option values list for all levels using SQLPlus).

    Kind regards
    Hussein

  • Help (recovery of the image of an xml file name, then appear inside the movieclip

    Hello guys, I just want to ask sometihng about the display of the image inside the movieclip by pulling on the image name in the xml file.

    It comes to my xml file.

    <? PHP

    Header ("Content-type: text/xml");

    $host = "localhost";

    $user = 'root ';

    $pass = "";

    $database = "test";

    $gelo = "image1.jpg";

    / * xml output * /.

    $xml_output = ' <? XML version=\"1.0\? > ';

    $xml_output. = "< GALLERY > ';

    $xml_output. = '< IMAGE > '. $gelo. "< / IMAGE >";

    $xml_output. = "< / GALLERY > ';

    echo $xml_output;

    ? >

    This is the code inside my actionscript

    stage.scaleMode = StageScaleMode.NO_SCALE;

    var loader: URLLoader = new URLLoader();

    loader.dataFormat = URLLoaderDataFormat.TEXT

    loader.addEventListener (Event.COMPLETE, loadCompleteHandler);

    loader.load (new URLRequest ("http://localhost/loadimagefromxmlAS3/data.php"));

    function loadCompleteHandler(event:Event):void {}

    var xml = new XML (event.target.data);

    txt.text = xml.toXMLString ();

    trace (xml. IMAGE [0]);

    var list: XMLList = xml.data.title

    var loader: Loader = new Loader()

    This ["holder_mc" + 0]. AddChild (Loader)

    Loader.Load (new URLRequest (list [0]. IMAGE))

    }

    When I run it in flash, I got the error


    Image1.jpg

    TypeError: Error #1010: a term is undefined and has no properties.

    at xml_fla::MainTimeline/loadCompleteHandler()

    at flash.events::EventDispatcher/dispatchEventFunction()

    at flash.events::EventDispatcher/dispatchEvent()

    at flash.net::URLLoader/onComplete()

    I hope you will consider my ignorance since im a beginner with actionscript. Thank you

    (1) you should have "Permit debugging" enabled in the settings of publication so you could tell exactly the line of witch will not

    (2) this line makes no sense for me: var list: XMLList = xml.data.title

    Change it to var list: XMLList = xml. IMAGE;

    (3) loader.load (new URLRequest (list [0] m:System.NET.SocketAddress.ToString (()));

    (4) also this line is suspicious: this ["holder_mc" + 0] .addChild (loader)

    Why not just say: holder_mc0.addChild (loader)?

  • What are all the default iOS image (homescreen) files names and directions for all devices?

    There is no conflicting information. What I do is the correct orientation of my splash screen for landscape modes.

    I would like to know the names of files and their respective directions. For example by default - LandscapeRight.png must be an upside? Retorical because it certainly does not work right.

    Haha never mind. 2 problems, I assumed that the image by default - LandscapeRight.png must be returned and I had by default - Landscape.png which is probably not necessary.

    http://iphonedevelopertips.com/iPad/iPad-managing-multiple-launch-images.html

    everything is ok now.

  • The analysis via an XML file

    Hello

    I work with an XML file that is generated through the API of Google Books.  I'll apologize in advance if I don't get quite accurate XML terminology - it's my first foray into some of the tags XML see  I'm reading a XML file in and attempt to send data:

    "< cfhttp url = 'http://www.google.com/books/feeds/volumes?q=john+grisham+the+firm & min-viewability biased =" method = "GET" > "

    < CFSET xmlfile = xmlparse (cfhttp.filecontent) >


    < cfset xmlsize = arraylen (xmlfile.feed.entry) >


    < cfloop from = "1" = "" #xmlsize # "index ="a">"

    < b > title: #xmlfile.feed.entry [a].title.xmlText # < /b > < br >
    < b > Format: #xmlfile.feed.entry [a].format.xmlText # < /b > < br >
    < b > author: #xmlfile.feed.entry [a].creator.xmlText # < /b > < br >
    < b > identifier1: #xmlfile.feed.entry [a].identifier.xmlText # < /b > < br >
    < b > identifier2: #xmlfile.feed.entry [a] .identify [2] .xmlText # < /b > < br >

    < / cfoutput >
    < / cfloop >

    It works pretty well.  Here's the problem: there is often a third identifier field (xmlfile.feed.entry [a] .identify [3] .xmlText)- but not always.

    I'm testing the existence of this field before you post.  I tried the following:

    < CFIF isdefined("xmlfile.feed.entry[a].identifier[3].xmlText") >
    is defined

    < CFELSE >

    is not defined
    < / cfif >

    Gives the typical error:

    Parameter 1 of function IsDefined, which is now xmlfile.feed.entry [a] .identify [3] .xmlText, must be a valid variable name syntactically.

    I would use structkeyExists, but I can't understand how the third node (?) using the reference code:

    < cfif structKeyExists(xmlfile.feed.entry[a],"identifier") > only works for xmlfile.feed.entry [a] .identify [1] .xmlText

    < cfif structKeyExists(xmlfile.feed.entry[a],"identifier[3]") > is not valid.

    So with strucktkeyexists, I can not understand how to properly reference the name of the variable...

    Any help?  Or the best ideas to verify the existence of this variable?

    The node you are looking at is an array, so:

    you need to do. At the present time, you test for the attribute 'xmltext' rather than to check its node parent exists.

    HTH.

  • File names image missing from the underside of the Photo Image

    I recently spoke with someone from Apple support and they confirmed that displaying the name of the file Image is a present feature in iPhoto, but was lost in the update photograph.  Their suggestion was to send feedback to Apple.  He said that it is the most effective way to get results and more of us than that best the chance we have to see this feature in a future update of photography.  It was my return to Apple:

    "Thank you for the update photograph... I appreciate some of the improved features that have been made for him. However, I would like to note that the absence of the names of files that appears under the image is cruelly.  I find this information very useful as I get pictures from other sources and helps determine the ownership of the photos.  Now, I'm a little lost without her.

    While the screen may look sharper and more user friendly for some, it would be good to know that this feature could be made available View (display Image File Name) option.

    Could I do that as a suggestion for your next release? »

    If you are also missing this feature, I encourage you to submit your comments to http://www.apple.com/feedback/photos.html

    iPhoto has used the names of files as a default title to be displayed as thumbnails, if no title has been assigned. Photo for Mac displays only the titles under the thumbnails, if a title had been awarded. He makes a distinction between a title assigned user and a file name.

    As a workaround: in the tip section the user to change the title of a photo file name - have a look, we have posted a few Scripts from Apple:

    Photos will show the title under the thumbnails if you select the titles in the menu: view > metadata.

    An alternative workaround: you get pictures of the power.  It allows you to browse your photo library with fields of metadata under the thumbnails - keywords, titles, names of files. You can customize what you want to see in the title or subtitle.

    But I support the request for better support of metadata in the pictures.  The feedback form is here: Feedback - Photos - Apple

  • Date, file name, the stamp

    I looked for hours to get a script that will work in Illustrator CS4 that will put a block of text on the page identification:

    Date, file name and the user name on the document (Council of art)

    I'm not versed in the scripts. Can someone help me?

    You just want to give this review. IM yet to learn this JavaScript stuff and I'm sure it can be cleaned.

    #target illustrator

    main() {} function

    If (app.documents.length == 0) {}

    Alert ("Please have an"Illustrator"document before running this script.");

    return;

    }

    var app.activeDocument = docRef;

    with (docRef) {}

    If (saved == false) save();

    var filePath = path;

    If (inCollection (linked text frames, "cartridge-file'")) {}

    frameA var = textFrames.getByName('titleblock-file');

    frameA.contents = name;

    }

    If (inCollection (linked text frames, "cartridge-path '")) {}

    frameB var = textFrames.getByName('titleblock-path');

    frameB.contents = unescape (fullName);

    }

    If (inCollection (linked text frames, "cartridge-date'")) {}

    frameC var = textFrames.getByName('titleblock-date');

    If (filePath.created! = null) {}

    var creatDate = filePath.created.toString ().split(' ');

    var creatDate = creatDate [1] + "" + creatDate [2] + "" + creatDate [3];

    frameC.contents = creatDate;

    }

    }

    If (inCollection (linked text frames, "cartridge-revised'")) {}

    Var box = textFrames.getByName('titleblock-revised');

    If (filePath.modified! = null) {}

    ModDate var = filePath.modified.toString ().split(' ');

    Var ModDate = ModDate [1] + ' ' + ModDate [2] + ' ' + ModDate [3];

    frameD.contents = ModDate;

    }

    }

    If (inCollection (linked text frames, ' titleblock-editor "")) {}

    War-horse var = textFrames.getByName('titleblock-editor');

    frameE.contents = "Mark Larsen"

    }

    }

    }

    main();

    function inCollection (ObjArr, "stringname") {}

    var x = false;

    for (var i = 0; i)< objarray.length;="" i++)="">

    If (ObjArr [i] .name == stringname) x = true;

    }

    Return x;

    }

  • Change the default copy and paste file or folder name to FileName (n)

    Hello

    I'm not sue if there is a correction that relates to windows or office other programs.

    I was wondering if there is an easy way, I could set up the default naming for files or the folders that I have copy and paste then. By example, if I copy a file called "Filename" and paste the copy in the same location, the name of the default copy is now given a name 'copy file name. Is it possible to change the default "FileName (n)" value, where n is 1 or 2 or... .depends on the question of whether or not a file with that number already exists.

    I use windows 7 and office 2010. I have a 'SuperCopier22beta' program that I think is the copy/paste?

    Thanks for the help.

    Hello

    There is not a way to change the default behavior of copy file name. There may be a 3rd party program, but common way is by design.

    Thanks and regards.

    Thahaseena M
    Microsoft Answers Support Engineer.
    Visit our Microsoft answers feedback Forum and let us know what you think.

  • How can I change the font color on the title of file name list in a folder?

    When you do a "file save as"..., type a document name... Can have the police on this document at a red name round (or other color) fonts for the list of files in the folder.  I want to be able to open the folder and have a file name "stand out" in other securities of black font in grip my eyes with red font?

    Vista does not have this capability.  There may be some 3rd party programs that might work for you, but I could find no one who were free and no coming to add this feature to Windows Explorer.

    Here "a s business option: http://www.xyplorer.com/index.htm but it's a pretty radical change (it is just to add the ability to change the fonts, colors file, and includes many other options, but it is not Windows
    Explorer - this is a totally different file manager) and it costs money so I do not recommend because I think that it is better to use a totally different program Windows Explorer, even if it means not to change the font color of file names.  And if you check, it's a bit expensive just to get this functionality (and who knows the other features of Windows Explorer that you like that you may lose with this alternative - don't really know us much and that it works well with Vidta or causes problems - maybe even serious problems as far as we know - because I know anyone who has ever tried it).

    Sorry if this isn't what you wanted to hear, but it's like that. I think the right answer is that Vista is not supported this feature, and then remove it.

    Good luck!

    Lorien - MCSA/MCSE/network + / has + - if this post solves your problem, please click the 'Mark as answer' or 'Useful' button at the top of this message. Marking a post as answer, or relatively useful, you help others find the answer more quickly.

Maybe you are looking for

  • Hot chocolate spilled on my keyboard - Qosmio E10

    I poured a small amount of hot chocolate on one side of my Qosmio E10. Oops! Since I gave it more than 24 hours to turn out to dry out and I also disassemble the keyboard to wipe - there was some residue dried hot chocolate in it. I'll try to put it

  • Flex sign in with a user ACL with APs switch locally

    Hi allFlex connects allow a user ACL to download the session with local authentication, dial-up, Central? We use ISE for the central policy engine and have the DACL of a wiring installation but am about to embark on WLAN. The controller is a 5508 and

  • How to extend timeline for more than 30 minutes

    How the calendar any longer because the default value is 30 minutes?

  • Write the Bootdisk SATADOM latency problem

    Hi people,I have a Supermicro Microcloud Pseudo-lame 8 Server identical blades, each installed with ESXi 5.5 on an edge D150QV Innodisk SATADOM (32 GB), with associated default datastore1 (about 24 GB) that has no virtual machine. A blade is a proble

  • How do I increasing width output of sqlplus?

    I use sqlplus on windows;SQL > select * from employees where rownum < 2;EMPLOYEE_ID FIRST NAME LAST NAME----------- -------------------- -------------------------E-MAIL PHONE_NUMBER HIRE_DATE JOB_ID SALARY------------------------- -------------------