We have a brand new look! Take a tour with us and explore the latest updates on Adobe Support Community.
I am working on a Photoshop script that writes data to txt file.
In the following folder structure example:
var pName = outputFolder.name writes Peaches to the txt file.
var mName = outputFolder.parent.name writes June to the txt file.
How can I define a variable that writes Summer Collection to the txt file and excludes the empty space %20 symbol?
Hope the question is clear. Let me know if you need additional details to clarify the question.
Copy link to clipboard
pName = path.name, mName = name; (txt = File(Folder.desktop + '/txt.txt')).open('w') txt.write(decodeURI(pName) + '/' + decodeURI(mName)), txt.close()
The code writes Adobe Photoshop 2021/Adobe Photoshop to the tx.txt file on the desktop.
While the open psd doc is locatedUser/Desktop/stack test/photoshopdoc.psd
Not sure why the name is automatically crossed over.
Should the script write User/Desktop to the txt.txt file on the desktop?
Each time you launch Photoshop, its name is automatically beeing assigned to variable, for example it is same for path). txt.txt is saved to desktop as seen in the code as I'm not mind-reader to know where you'd like it to be saved 😉 There is nothing about it in your original post so txt should be saved on desktop 🙂 path and name are used instead of outputFolder.
Thank you for clarifying. I am trying to write the directory WK22 only to a txt file when the script runs on a file that is located in the WIP directory. Is that possible and does it make sense?
Which bit are you having issues with?
Triggering the write if the file is located in the WIP directory?
Or manipulating the text string to only write WK22?
In the folder path sample, I can write the directory WIP and GNO to the txt file. I am having difficulty writing the directory WK22 to the file. The text file should look like this:
WK22, GNO, WIP
if ((nme = (pth = activeDocument.path).name) == 'WIP') alert([(prnt = pth.parent).parent.name, prnt.name, nme])
if ((pth = activeDocument.path).name == 'WIP') alert(pth.parent.parent.name)
This works well when the directory name is WIP. Is it possible to make the WIP variable so that independently from the name the code can get the name of the folder two levels up?
path == app.path
name == app.name
and cannot be changed
delete name; name = 'I\'m changed', alert(name), name = app.name, alert(name)
Thank you that works for me!