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: Tom, Kukurykus

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

one step up in folder structure

Post by Bardioch »

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

Post by wasfiwasfi »

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

Post by Bardioch »

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

Post by wasfiwasfi »

Do you mean search/scan for subfolders !?