Page 1 of 1

one step up in folder structure

Posted: Mon Nov 13, 2017 3:26 pm
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);}
}

Re: one step up in folder structure

Posted: Thu Nov 16, 2017 3:00 pm
by wasfiwasfi

Code: Select all

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

Re: one step up in folder structure

Posted: Fri Nov 17, 2017 1:32 pm
by Bardioch
Oh sorry, i meant the oposite... :?

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

Re: one step up in folder structure

Posted: Sat Nov 18, 2017 11:27 pm
by wasfiwasfi
Do you mean search/scan for subfolders !?