one step up in folder structure

Anyone, especially newbies, asking for help with Photoshop Scripting and Photoshop Automation - as opposed to those contributing to discussion about an aspect of Photoshop Scripting

Moderators: xbytor, DavideBarranca, Paul MR

Bardioch
Posts: 4
Joined: Tue Sep 19, 2017 1:00 pm

one step up in folder structure

Postby Bardioch » Mon Nov 13, 2017 3:26 pm

Hey guy´s

Instead of putting my picture in the same folder as the current one, I would like to move it one step up the folder structure.

Is this possible???

Because i tried it with ../ as i found in some descriptions and nothing happend... :(

I hope somebody could help me out or give me a hint :D

Thx, Bardioch

Code: Select all

var thedoc=app.activeDocument;
var docName = thedoc.name;
if (docName.indexOf(".") != -1) {var basename = docName.match(/(.*)\.[^\.]+$/)[1]}
else {var basename = docName};
try {var docPath = thedoc.path}
catch (e) {var docPath = "~/Desktop"};
var folderString = docPath+"/FolderABC"; //Thats where i want to make one step up in folder structure

var theCopy = thedoc.duplicate(basename,false);
OutFoldJPEG(folderString,basename,12,true,MatteType.NONE,Extension.LOWERCASE);
theCopy.close(SaveOptions.DONOTSAVECHANGES);

function SaveJPEG(saveFile, jpegQuality,cProfile,MType,fCase){
jpgSaveOptions = new JPEGSaveOptions();
jpgSaveOptions.embedColorProfile = cProfile;
jpgSaveOptions.formatOptions = FormatOptions.STANDARDBASELINE;
jpgSaveOptions.matte = MType;
jpgSaveOptions.quality = jpegQuality;
activeDocument.saveAs(saveFile, jpgSaveOptions, true,fCase);
}

function OutFoldJPEG(docPath,dnme,jpegQuality,cProfile,MType,fCase){
var outfolder = new Folder(docPath)
if (outfolder.exists == false){
outfolder.create();
var saveFile = new File(outfolder + "/" + dnme);
SaveJPEG(saveFile, jpegQuality,cProfile,MType,fCase);}
else{
var saveFile = new File(outfolder + "/" + dnme);
SaveJPEG(saveFile, jpegQuality,cProfile,MType,fCase);}
}

wasfiwasfi
Posts: 45
Joined: Fri Nov 04, 2016 8:29 am

Re: one step up in folder structure

Postby wasfiwasfi » Thu Nov 16, 2017 3:00 pm

Code: Select all

var folderString = docPath.parent+"/FolderABC";

Bardioch
Posts: 4
Joined: Tue Sep 19, 2017 1:00 pm

Re: one step up in folder structure

Postby Bardioch » Fri Nov 17, 2017 1:32 pm

Oh sorry, i meant the oposite... :?

My js knowledge is growing slowly but thats ohne of the things i know already ;)

wasfiwasfi
Posts: 45
Joined: Fri Nov 04, 2016 8:29 am

Re: one step up in folder structure

Postby wasfiwasfi » Sat Nov 18, 2017 11:27 pm

Do you mean search/scan for subfolders !?


Return to “Help Me”

Who is online

Users browsing this forum: No registered users and 5 guests