Script to change layer name in to Document name.

Hi I would like to make the active layer name the same as the document name.  I know very little about scripting.  I found this script:
var idoc = app.activeDocument;
var ilayer = idoc.activeLayer;
var filename = idoc.name;
ilayer.name = filename;
It does almost what I need it to do. except that it also copies the ".ai" in to the layer name.  Is there some way to modify this script to have it exclude or delete the file extension?
Thanks for any help.

Or, if you want to keep the same construction as your example...
var idoc = app.activeDocument;
var ilayer = idoc.activeLayer;
var filename = idoc.name;
filename = filename.slice (0, filename.lastIndexOf(".")); //just add this line to the construction.
ilayer.name = filename;
Gustavo.

Similar Messages

  • Need help writing script to change version control for all document libraries in all sites

    Hello,
    I found this script, http://get-spscripts.com/2010/10/changing-sharepoint-list-settings-using.html that
    changes versions control for a document library.  However, many sites have many document libraries with different names.  The script below just changes a the settings to a document library that is named "Shared Documents", but does not
    change one if its named something else.  How can change the script to loop through all document libraries so their settings are changed?
    $site = Get-SPSite http://site
    $listName = "Shared Documents"
    #Walk through each site in the site collection
    $site | Get-SPWeb | 
    ForEach-Object {
    #Get the list in this site
    $list = $_.Lists[$listName]
    #Create a version each time you edit an item in this list (lists)
    #Create major versions (document libraries)
    $list.EnableVersioning = $true
    #Create major and minor (draft) versions (document libraries only)
    $list.EnableMinorVersions = $true
    #Keep the following number of versions (lists)
    #Keep the following number of major versions (document libraries)
    $list.MajorVersionLimit = 7
    #Keep drafts for the following number of approved versions (lists)
    #Keep drafts for the following number of major versions (document libraries)
    $list.MajorWithMinorVersionsLimit = 5
    #Update the list
    $list.Update()
    #Dispose of the site object
    $site.Dispose()
    Paul

    Sorry, I agree. It will update Style Library and other out of the box ones. Include the library titles in a collection and run the update against them provided these libraries are common across all sites. If not, you will have to first get an extract of
    all such libraries in all sites say in a CSV file and then update the script below to refer to the CSV records.
    Add-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction Stop;
    #List of Libraries to be updated.
    $Libraries = @("Shared Documents","My Document Library");
    $spAssgn = Start-SPAssignment;
    $site = Get-SPSite http://site -AssignmentCollection $spAssgn
    #Walk through each site in the site collection
    $site | Get-SPWeb -Limit ALL -AssignmentCollection $spAssgn |
    ForEach-Object {
    #Enumerate through all document libraries
    $_.Lists|Where{$_.BaseTemplate -eq "DocumentLibrary" -and $Libraries -contains $_.Title}|Foreach-Object{
    #Get the list in this site
    $list = $_;
    #Create a version each time you edit an item in this list (lists)
    #Create major versions (document libraries)
    $list.EnableVersioning = $true
    #Create major and minor (draft) versions (document libraries only)
    $list.EnableMinorVersions = $true
    #Keep the following number of versions (lists)
    #Keep the following number of major versions (document libraries)
    $list.MajorVersionLimit = 7
    #Keep drafts for the following number of approved versions (lists)
    #Keep drafts for the following number of major versions (document libraries)
    $list.MajorWithMinorVersionsLimit = 5
    #Update the list
    $list.Update()
    Stop-SPAssignment $spAssgn;
    This post is my own opinion and does not necessarily reflect the opinion or view of Slalom.

  • Is there a script for changing layer names in ID CS4?

    I have multiple documents with an average of 20 layers in each. Each of the layers is named for the expiration date of the coupon in the ads. When a new order comes in I retrieve the previous files and change the dates via scripts and the Find/Change option. I have looked but cannot find a way to rename the dates in the layers as well.
    Does anyone know of a script for this?
    Thanks in advance!

    E-mail, eh? You're missing out a lot of fun stuff, as there is
    - editing your own posts
    - using bold and italics to highlight important stuff
    - finally being able to shout (some posters think it's necessary to use a large bold font to make their post stand out in the crowd. They are correct, it does. In the Bad way.)
    - inserting images
    - uh, Jive (-- sorry, couldn't think of any more fun stuff to add)
    Visit the scripting forum (using a web browser, s'il vous plait) by clicking here.

  • Powershell script to change the a column value of all documents in a site.

    Hi,
    I need a powershell script to change the value of a column (a site column which has been added to all document libraries) in all documents in a site,
    For example: 
    -column 1 is a site column added to all libraries
    the value of column 1 of all documents under this site: http://intranet.doman/ex1 should be equal to V1
    the value of column 1 of all documents under this site: http://intranet.doman/ex2 should be equal to V2
    So, if I can write a powershell script to change the value of all documents in a site, I can modify it for different site that I have and run it for each of them individually,

    cls
    # Is dev version?
    $dev = $false
    # Configuration
    $termStore = "Managed Metadata Service"
    $group = "G1"
    $subjectMatterTermSetName = "Subject Matter"
    # Check if SharePoint Snapin is loaded
    if((Get-PSSnapin | Where {$_.Name -eq "Microsoft.SharePoint.PowerShell"}) -eq $null) {
         Add-PSSnapin Microsoft.SharePoint.PowerShell
    [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Taxonomy") | Out-Null
    function GetTermStore($site, $termStore, $group, $termSet) {    
        $session = New-Object Microsoft.SharePoint.Taxonomy.TaxonomySession($site)
        $termStore = $session.TermStores[$termStore]
        $group = $termStore.Groups[$group]
        $termSet = $group.TermSets[$termSet]
        return $termSet
    if($dev) {
        Write-Host "Running DEV version..."
        $webUrl = "http://Site1"   
        $libraryName = "L1"
        $subjectMatter = "C1"
    } else {
        $webUrl = Read-Host "Enter Site URL" 
        $libraryName = Read-Host "Enter Document Library name"
    $subjectMatter = Read-Host "Enter Subject Matter"
    try {
        $web = Get-SPWeb $webUrl
        $site = $web.Site
        $library = $web.Lists[$libraryName]
        $items = $library.GetItems()
        $subjectMatterTermSet = GetTermStore $site $termStore $group $subjectMatterTermSetName
        $subjectMatterTerm = $subjectMatterTermSet.GetTerms($subjectMatter,$true) | select -First 1
        foreach($item in $items) {
            if([string]::IsNullOrEmpty($item["Subject Matter"])) {     
                #Write-Host "Filename: $filename / Keywords: $keywords / Subject Matter: $subjectMatter / Document Type: $documentType"        
                Write-Host "Updating $($item["ows_FileLeafRef"])..."           
                # Set Subject Matter column
                $subjectMatterField = [Microsoft.SharePoint.Taxonomy.TaxonomyField]$item.Fields["Subject Matter"]
                $subjectMatterField.SetFieldValue($item,$subjectMatterTerm)
                # Update Item
                $item.SystemUpdate()
    catch
        $ErrorMessage = $_.Exception.Message
        Write-Host "Something went wrong. Error: $ErrorMessage" -ForegroundColor Red

  • Adding name of indesign document to metadata of all images used in document

    I have been asked to include the indesign file name in the metatag of each image used in every document i produce from here on.
    is there a way to write a script in indesign that will copy the document name then open every link (in bridge?) and append the document name to the metadata (i don't want to lose any existing tags) and then save?
    scott

    This should should give you a start. It'll add the active documents name to the field instructions of the img when executed. Tested once. No errorhandling.
    currDoc = app.activeDocument;
    docName = currDoc.name;
    docGraphics = currDoc.allGraphics;
    for(var g = 0; g < docGraphics.length; g++){
        currGraphic = docGraphics[g];
            currGraphicFilePath = currGraphic.itemLink.filePath;
            fileObject = File(currGraphicFilePath);
    writeDocNameToMeta(fileObject, docName);
    function writeDocNameToMeta(fileObject, docName){
    if(loadXMPLibrary()){
            var myFile = fileObject;
            xmpFile = new XMPFile(myFile.fsName, XMPConst.UNKNOWN, XMPConst.OPEN_FOR_UPDATE);
            var myXmp = xmpFile.getXMP();
                  var myStatus = myXmp.getProperty(XMPConst.NS_PHOTOSHOP,"Instructions");
       myXmp.deleteProperty(XMPConst.NS_PHOTOSHOP, "Instructions");
       myXmp.setProperty(XMPConst.NS_PHOTOSHOP, "Instructions", docName);
       if (xmpFile.canPutXMP(myXmp)) {          xmpFile.putXMP(myXmp);    }
            xmpFile.closeFile(XMPConst.CLOSE_UPDATE_SAFELY);
            unloadXMPLibrary();
        function loadXMPLibrary(){
            if ( !ExternalObject.AdobeXMPScript ){
                try{ExternalObject.AdobeXMPScript = new ExternalObject('lib:AdobeXMPScript');}
                catch (e){alert('Unable to load the AdobeXMPScript library!'); return false;}
            return true;
    function unloadXMPLibrary(){
            if( ExternalObject.AdobeXMPScript ){
                try{ExternalObject.AdobeXMPScript.unload(); ExternalObject.AdobeXMPScript = undefined;}
                catch (e){alert('Unable to unload the AdobeXMPScript library!');}
    Hans-Gerd Claßen

  • Script for document name labels

    How hard would this be?
    A script that would type the file name into the document. I searched for similar threads but no luck. Here are the details...
    1. If the document was named TEST.pdf the script would type TEST in the document.
    2. The font color, size, and type would be Black, Arial Bold,  0.4 in.
    3. The font would be converted to outlines.
    4. A rectangle 0.05" larger than text would be placed around the text.
    5. The rectangle would have no fill and a 100% magenta spot color named "CC" stroke.
    6. The rectangle stroke would be moved to the CC layer (pre-existing layer).
    7. The text "TEST" would be moved to the Artwork layer  (pre-existing layer).
    Thanks for any input or help.
    Anton

    Anton, this should be pretty close for a guide… I don't know what your exact font name would be… so this uses my closest match. Also you don't mention text positioning on the artboard/doc… The stroke is default 1pt as is. The height of the outlined text would be dependent on your font and you may have to tinker with the size where shown…
    #target illustrator
    function docNameToText() {
         if (app.documents.length = 0) {
              return;
         } else {
              var docRef = app.activeDocument;
              var docName = docRef.name;
              var text = docName.replace(/\.(ai|eps|pdf)$/i,'');
              var arialFont = app.textFonts.getByName('ArialMT-Bold'); // Add font name here…
              var nameText = docRef.textFrames.add();
              nameText.contents = text;
              var nameChar = nameText.lines[0].characters;
              for (var i = 0; i < nameChar.length; i++) {
                   nameChar[i].characterAttributes.textFont = arialFont;
                   nameChar[i].characterAttributes.size = 40; // Adjust font size here…
              var textGroup = nameText.createOutline();
              textGroup.position = [36,-36]; // Half Inch down/across from top/left
              var groupBounds = textGroup.visibleBounds;
              var ccLayer = docRef.layers.getByName('CC');
              textGroup.move(ccLayer, ElementPlacement.INSIDE);
              var artLayer = docRef.layers.getByName('Artwork');
              // This can't be the right way to do this now can it?
              var boxTop = groupBounds[1] + 4;
              var boxLeft = groupBounds[0] - 4;
              var boxWidth = (groupBounds[2] - groupBounds[0]) + 8;
              var boxHeight = (-groupBounds[3] - -groupBounds[1]) + 8;
              var spotBox = docRef.pathItems.rectangle(boxTop,boxLeft,boxWidth,boxHeight);
              spotBox.filled = false;
              spotBox.stroked = true;
              //spotBox.strokeWidth = 1; // Default is 1pt
              var ccSpot = docRef.swatches.getByName('CC');
              spotBox.strokeColor = ccSpot.color;
              textGroup.move(artLayer, ElementPlacement.INSIDE);
    docNameToText();

  • Can I script the changing of creation date, using the file name?

    Normally people are doing this in reverse, but let me paint the picture.
    I pulled 204 video files from an old HDD based JVC camera.  JVC records in .MOD format which iPhoto won't import.  I imported them into iMovie just fine, and iMovie even set the file name to clip-2007-11-04 04;42;29.mov which is great, but it now has a new creation date of whatever date I imported it.  Which then causes problem when I want the videos stored in iPhoto and sorted appropriately by creation date.
    I've used the application "A Better Finder Attributes 5" to individually edit the creation and modify, but I'm sure I don't want to do this 203 more times, as you can't just type in the date and time, you have to type in each part of the date/time, or select it on a calendar.
    I've used the application "Name Changer" to batch convert the file names to the format YYYYMMDDhhmm which would be helpful if I were going to use the terminal command touch -t, but again I don't want to have to type it in 203 more times, plus drag and drop the file into finder to populate the location.
    Now, if I were more handy with automator, or maybe some (any) scripting language this would be easy peasy.  I'd batch rename all the files to the YYYYMMDDhhmm.mov and then have a script that just took the file name, passed that to touch -t along with the file location, and a few seconds later, they would all be done!
    Anybody have any suggestions to how I can do this, and tips to what commands to use or ANY advice?  I'm more than happy to RTFM, but I have no idea which manual to read!
    Thanks

    If your file names are precisely as you have written, this script will do what you want.
    Copy the script into an AppleScript Editor document, select one or more files in a Finder window, return to the AS Editor and press Run.  Note: you will need to provide your password when the script runs.
    Make sure you have a backup of any files you are working on (try using duplicates first, perhaps). The script has no error handling.
    tell application "Finder"
              set FileList to selection
              repeat with theFile in FileList
                        set fileName to name of theFile
                        set filePath to quoted form of (POSIX path of (theFile as alias))
                        set crYear to text 6 thru 9 of fileName
                        set crMonth to text 11 thru 12 of fileName
                        set crDay to text 14 thru 15 of fileName
                        set crHour to text 17 thru 18 of fileName
                        set crMins to text 20 thru 21 of fileName
                        set crDate to crYear & crMonth & crDay & crHour & crMins
                        set shellString to "touch -t " & crDate & " " & filePath
      do shell script shellString with administrator privileges
              end repeat
    end tell

  • Script to change name of author

    Does anyone have a script which will:
    1. Prompt for the name of the name of an author for mark-up eg underlining;
    2. Change the name of the author.
    The script would typically be deployed in the following circumstances:
    1. you have a large document you want to analyse;
    2. you apply mark-up to selected aspects
    3. you change the name of the author to tag the relevant aspects thereby creating a series of themes
    4. This gives you the ability to negotiate through the document by theme

    answered

  • Script to search layer names

    Hi -
    Does anyone know if there is a script that can search through layer names within a file for a specific text string and then select it as the active layer?
    For instance, if a file has 4 layers, named My LayerX, LayerY, LayerZ, LayerA, I want to automatically search for a layer that has the text "rA" and make it the active layer.
    Thanks.

    This requires CS4 or better. It searchs using a RegExp and Action Manager so it should be very fast. It is set up now to deal with more than one matching layer.
    var re = /rA/;// a reg exp
    var matches = collectNamesAM(re);// get array of matching layer indexes
    for( var l = 0; l < matches.length; l++ ){
        makeActiveByIndex( l, false );
        // do something with layer
        alert(app.activeDocument.activeLayer.name);
    }// next match if any
    function collectNamesAM(re){
         var allLayers = new Array();
       var startLoop = Number( !hasBackground() );
       var endLoop = getNumberOfLayer();
       for( var l = startLoop;l < endLoop; l++){
            while( !isValidActiveLayer( l ) ) {
                l++;
            if( getLayerNameByIndex( l ).match(re) != null){
                allLayers.push( l );
         return allLayers;
    // Function: getActiveLayerIndex
    // Description: Gets gets the Action Manager API index
    //                        of activeLayer corrected for Background Layer
    // Usage: var idx = getActiveLayerIndex();
    // Input: None
    // Return: Number - correct AM itemIndex
    // Dependices: hasBackground
    function getActiveLayerIndex() {
         var ref = new ActionReference();
         ref.putProperty( 1349677170 , 1232366921 );
         ref.putEnumerated( 1283027488, 1332896878, 1416783732 );
         var res = executeActionGet(ref).getInteger( 1232366921 )
                                                           - Number( hasBackground() );
         res == 4 ? res++:res// why the skip in this doc?
         return res;  
    // Function: isValidActiveLayer( )
    // Description: Checks LayerSection for 'real' layers
    // Usage: if( isValidActiveLayer() )
    // Input: None
    // Return: Boolean - True if not the end of a Set
    // Notes:  Needed only if the layer was made active
    //               using Action Manager API
    function isValidActiveLayer( idx ) {
         var propName = stringIDToTypeID( 'layerSection' );// can't replace
         var ref = new ActionReference();
         ref.putProperty( 1349677170 , propName);// TypeID for "Prpr"
         // 'Lyr ", idx
         ref.putIndex( 1283027488, idx );
         var desc =  executeActionGet( ref );
         var type = desc.getEnumerationValue( propName );
         var res = typeIDToStringID( type );
         return res == 'layerSectionEnd' ? false:true;
    // Function: hasBackground
    // Description: Test for background layer using AM API
    // Usage: if( hasBackground() );
    // Input: None
    // Return: Boolean - true if doc has background layer
    // Notes:  Requires the document to be active
    //  DOM:  App.Document.backgroundLayer
    function hasBackground(){
        var res = undefined;
        try{
            var ref = new ActionReference();
            ref.putProperty( 1349677170 , 1315774496);
            ref.putIndex( 1283027488, 0 );
            executeActionGet(ref).getString(1315774496 );;
            res = true;
        }catch(e){ res = false}
        return res;
    function makeActiveByIndex( idx, forceVisible ){
         try{
              var desc = new ActionDescriptor();
              var ref = new ActionReference();
              ref.putIndex(charIDToTypeID( "Lyr " ), idx)
              desc.putReference( charIDToTypeID( "null" ), ref );
              desc.putBoolean( charIDToTypeID( "MkVs" ), forceVisible );
              executeAction( charIDToTypeID( "slct" ), desc, DialogModes.NO );
         }catch(e){ return -1;}
    function getNumberOfLayer(){
    var ref = new ActionReference();
    ref.putEnumerated( charIDToTypeID("Dcmn"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
    var desc = executeActionGet(ref);
    var numberOfLayer = desc.getInteger(charIDToTypeID("NmbL"));
    return numberOfLayer;
    function getLayerNameByIndex( idx ) {
        var ref = new ActionReference();
        ref.putProperty( charIDToTypeID("Prpr") , charIDToTypeID( "Nm  " ));
        ref.putIndex( charIDToTypeID( "Lyr " ), idx );
        return executeActionGet(ref).getString(charIDToTypeID( "Nm  " ));;

  • Script to copy Layer/Group to another Open Document?

    Hi, I know this topic has been covered many times before. But to clarify, here's what I'm wondering:
    Copy the active layer/group to another open document in Photoshop. The simple way is to go to "Layer/Duplicate Layer..." . But this is very tedious. For starters, when you choose that method, and then select the document that you'd like to copy to via the pull-down menu, it successfully copies the layer/group to that document, but it doesn't auto-switch (activate) to the document it was just copied to. You have to hit "Ok", and then manually search through the open documents list via (Window/*choose your document*) to get there. This is a nightmare when you're trying to do this many times.
    Here is what I am wondering:
    Is it possible to:
    a) copy the active layer/group to the clipboard/memory
    b) switch to another existing document in Photoshop *via a custom menu* which shows all existing documents
    c) once switched to the new existing document, paste that layer/group from the clipboard into that document
    ..is that possible?
    At the very least, are there any scripts that anyone knows of that allows the user to switch between existing documents via a custom menu instead of going to Window/*choose your document* ?

    This might help with Groups and some other kinds of Layers.
    But it takes the easy route with the target file by using the name to identify it.
    // some amendments to pixxxelschubser’s code;
    // 2014, use it at your own risk;
    #target photoshop
    var aDoc = app.activeDocument;
    var AllDocs = app.documents;
    var actLay = aDoc.activeLayer;
    var theIndex = getSelectedLayersIdx();
    if (AllDocs.length > 1) {
    var itemDoc = null;
    var win = new Window("dialog","Copy the active layer");
    this.windowRef = win;
    win.Txt1 = win.add ("statictext", undefined, "Paste in which open document?");
    win.NewList=win.add ("dropdownlist", undefined)
    for (var m = 0; m < AllDocs.length; m++) {
    win.NewList.add("item", AllDocs[m].name)
    win.NewList.selection = 0;
    itemDoc = win.NewList.selection.index;
    win.cancelBtn = win.add("button", undefined, "Abbruch");
    win.quitBtn = win.add("button", undefined, "Ok");
    win.defaultElement = win.quitBtn;
    win.cancelElement = win.cancelBtn;
    win.quitBtn.onClick = function() {
    win.close();
    win.NewList.onChange= function () {
        itemDoc = win.NewList.selection.index;
        return itemDoc;
    win.show();
    // duplicate layers;
    for (var n = 0; n < theIndex.length; n++) {
    duplicateLayer (theIndex[n], String(win.NewList.selection))
    app.refresh();
    } else {
        alert ("No other documents open")
    ////// duplicate layer //////
    function duplicateLayer (theIndex, theDoc) {
    // =======================================================
    var idDplc = charIDToTypeID( "Dplc" );
        var desc7 = new ActionDescriptor();
        var idnull = charIDToTypeID( "null" );
            var ref3 = new ActionReference();
        ref3.putIndex(charIDToTypeID("Lyr "), theIndex);
        desc7.putReference( idnull, ref3 );
        var idT = charIDToTypeID( "T  " );
            var ref4 = new ActionReference();
            var idDcmn = charIDToTypeID( "Dcmn" );
            ref4.putName( idDcmn, theDoc );
        desc7.putReference( idT, ref4 );
        var idVrsn = charIDToTypeID( "Vrsn" );
        desc7.putInteger( idVrsn, 5 );
    executeAction( idDplc, desc7, DialogModes.NO );
    ////// by paul mr;
    function getSelectedLayersIdx(){
          var selectedLayers = new Array;
          var ref = new ActionReference();
          ref.putEnumerated( charIDToTypeID("Dcmn"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
          var desc = executeActionGet(ref);
          if( desc.hasKey( stringIDToTypeID( 'targetLayers' ) ) ){
            desc = desc.getList( stringIDToTypeID( 'targetLayers' ));
              var c = desc.count
              var selectedLayers = new Array();
              for(var i=0;i<c;i++){
                try{
                  activeDocument.backgroundLayer;
                  selectedLayers.push(  desc.getReference( i ).getIndex() );
                }catch(e){
                  selectedLayers.push(  desc.getReference( i ).getIndex()+1 );
          }else{
            var ref = new ActionReference();
            ref.putProperty( charIDToTypeID("Prpr") , charIDToTypeID( "ItmI" ));
            ref.putEnumerated( charIDToTypeID("Lyr "), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
            try{
                activeDocument.backgroundLayer;
                selectedLayers.push( executeActionGet(ref).getInteger(charIDToTypeID( "ItmI" ))-1);
            }catch(e){
                selectedLayers.push( executeActionGet(ref).getInteger(charIDToTypeID( "ItmI" )));
          return selectedLayers;

  • How do you change the name of a document in pages on an iPod touch?

    I am on my iPod touch and I want to name my document in Pages. How do I do it?? I know you can, but how??

    nevermind! I figured it out!! You just have to be in where all your documents are shown, hold the NAME (not the document it self, the name of the document) and if you hold it (tap it) for long enough, it will bring up the change document name screen.

  • Document name keeps changing

    I have often been puzzled as to why a document name changes.
    E.g. In simple terms. I login to an account, navigate to a page, check a phone number on the screen is correct. It would seem simple wouldn't it.But if I login to one account the document name is different to when I login to another account.
    e.g.
    var phoneNum = this.UIMap.UIWindowName.UIDocumentName.UIItemCustom.InnerText;
    var phoneNum = this.UIMap.UIWindowName.UIDocumentName5.UIItemCustom.InnerText;
    How do I overcome this? Is it possible to overcome this easily?
    And furthermore, why does this happen?

    Hi UncleZen_,
    The coded UI test builder recorder just recorded the actions on your UI, the reason why the specific controls have the dynamic name or why it always changes with different log in users, it would be related to the app developer, so if
    possible, you could discuss this issue with the development team members, I think you could get more useful information. So it would be not the test issue.
    Sincerely,
    Jack
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Changing the document name on IBooks

    How do I change the name of a document thats saved on IBooks?

    I'm not sure you can if you are talking about PDF files. You can rename the PDF in Adobe Reader app( it's a free app) and then send it to iBooks. Maybe others on the forum know of a better way.

  • Change document name in event receiver

    I need to rename a document during an ItemUpdating or an ItemUpdated event. Either one would be fine. When my user changes the file name, I want my code to set it to something else. In the examples below, I am trying to set it to a silly constant value.
    If I can get this to work, I'll change it to use something meaningful.
    Is there any way to change a document's name in an event receiver? I have tried using ItemUpdated (with <Synchronization>Synchronous</Synchronization> in elements.xml). I have tried this:
    public override void ItemUpdated(SPItemEventProperties properties)
    using (DisabledEventsScope scope = new DisabledEventsScope())
    base.ItemUpdated(properties);
    try
    properties.Web.AllowUnsafeUpdates = true;
    properties.ListItem.File.Properties["FileLeafRef"] = "FOOFOO.docx";
    properties.ListItem.File.Update();
    properties.Web.AllowUnsafeUpdates = false;
    catch (Exception ex)
    properties.ErrorMessage = "Document cannot be renamed." + ex.Message;
    properties.Status = SPEventReceiverStatus.CancelWithError;
    //base.ItemUpdated(properties);
    I have also tried this:
    public override void ItemUpdated(SPItemEventProperties properties)
    using (DisabledEventsScope scope = new DisabledEventsScope())
    base.ItemUpdated(properties);
    try
    properties.Web.AllowUnsafeUpdates = true;
    properties.AfterProperties["FileLeafRef"] = "FOOFOO.docx";
    properties.ListItem.Update();
    properties.Web.AllowUnsafeUpdates = false;
    catch (Exception ex)
    properties.ErrorMessage = "Document cannot be renamed." + ex.Message;
    properties.Status = SPEventReceiverStatus.CancelWithError;
    //base.ItemUpdated(properties);
    And in that last one, I also tried setting properties.ListItem["FileLeafRef"]. I have also tried putting the base.ItemUpdated line after my logic (where you see it commented out above).
    Nothing works. No errors are thrown, but the document name stays the way the user set it.
    Leigh Webber

    There's three things you have to do in order to update the name properties:
    Assign properties.ListItem to a variable
    Update the BaseName field
    Update the Type field (if you wish to change the extension)
    public override void ItemUpdated(SPItemEventProperties properties)
    EventFiringEnabled = false;
    base.ItemUpdated(properties);
    var item = properties.ListItem; item["BaseName"] = "BarBar";
    item["Type"] = "docx"; //If you need to change the extension
    item.Update();
    EventFiringEnabled = true;
    This should fix your issue

  • Changing Document Name of unsaved File

    Hi,
    is it possible to change the name of an opened but not saved document?
    If I open a photo from ACR as an object, PS will append "as object" to the document name.
    I'd like to delete that part of the document name, BEFORE it will be saved.
    Or is there another way to do that?
    app.activeDocument.name is read only...
    Thanks!

    Try this:
    -X
    var original = app.activeDocument;
    var newDoc = original.duplicate(original.name.replace(' as object', ''));
    original.close(SaveOptions.DONOTSAVECHANGES);

Maybe you are looking for