gpt4 book ai didi

image - Photoshop 脚本将文件名作为文本添加到图像,但删除前两个字符

转载 作者:行者123 更新时间:2023-12-01 03:39:26 28 4
gpt4 key购买 nike

我找到了一个脚本,它将获取我的图像的文件名并将其放在图像上,减去文件扩展名。我已将此添加到一个操作中,该操作完美无缺,但是我的文件名有前导数字(01、02、03 等)以将它们保持在特定顺序。前导数字只有两位数。

是否可以编辑此脚本以将文件名放在我的图像上时从文件名中删除前两个数字?我希望数字保留在文件名中,而不是图像中。

例如: 01Firstfile = Firstfile 放置在图像上时。

这是我找到脚本的链接:http://blogs.adobe.com/jkost/2010/09/add-file-name-as-text-layer.html

我已经搜索并搜索了答案,最后决定只询问是否有人可以帮助我。如果这已经得到回答而我找不到它,我深表歉意。

下面是脚本的一部分。我试图把整个脚本放在这里,但它一直给我一个错误。

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 fileNameNoExtension = docRef.name;
fileNameNoExtension = fileNameNoExtension.split( "." );
if ( fileNameNoExtension.length > 1 ) {
fileNameNoExtension.length--;
}
fileNameNoExtension = fileNameNoExtension.join(".");

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;

最佳答案

改变:
myTextRef.contents = fileNameNoExtension;
到:
myTextRef.contents = fileNameNoExtension.substring(2);

关于image - Photoshop 脚本将文件名作为文本添加到图像,但删除前两个字符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31914725/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com