Hello again,
I use the script almost every day since two years but now that i've got cs6 and that i try to look to work more with bridge, i realized that when i launch the script from bridge, it simply launch the window export for web instead of doing a silent export. I've only got this problem from bridge, from ps everything works perfectly.
Do you know if it's possible to change that?
Here is the final code i use:
Code: Select allfunction createFolder( folderObj ){
if( !folderObj.parent.exists ) createFolder( folderObj.parent );
if( !folderObj.exists ) folderObj.create();
};
function exportSFW( doc, saveFile, qty ) {
var exportOpts = new ExportOptionsSaveForWeb( );
exportOpts.format = SaveDocumentType.JPEG
exportOpts.includeProfile = true;//default false
exportOpts.quality = qty;
if ( saveFile.exists ) saveFile.remove( );
doc.exportDocument( saveFile, ExportType.SAVEFORWEB, exportOpts );
};
// make a new folder object from the doc path and change the structure from to-do to done. Note the folder being replace should not the doc path.parent
// S:\to do\folderA\subfolder36 to S:\done\folderA\subfolder36 not S:\to do\folderA\subfolder36 to S:\to do\folderA\subfolder37
var strPath = decodeURI( app.activeDocument.path );
strPath = strPath.replace( 'work', 'ret');
//strPath = strPath+'-retouched';
//strPath = strPath.replace(/\/.{3}\//, '/' );// will remove the first three char folder in the path
var saveFolder = new Folder( strPath )
createFolder( saveFolder );
var saveFile = new File( saveFolder + '/' + app.activeDocument.name );// assumes doc was a jpeg when opened if not change extension
// do your save for web step here using saveFile
exportSFW( app.activeDocument, saveFile, 80 );
Exporting for the web, recreating folder structure
-
karm
Exporting for the web, recreating folder structure
Using this script everyday, when i launch it on a folder containing png or other extensions, the script keeps the original extension. So i need to rename each file from png (for example) to jpg after the script.
Is there a way that the script could force the exit extension to be jpg?
Is there a way that the script could force the exit extension to be jpg?
-
Mike Hale
Exporting for the web, recreating folder structure
Sorry, I made a comment in the code I posted that it expects the document to have been opened from a jpeg file and the extension would need to be changed if it was not. But I sometimes forget that comments might not be helpful to people with no/little scripting experience.
Code: Select allfunction createFolder( folderObj ){
if( !folderObj.parent.exists ) createFolder( folderObj.parent );
if( !folderObj.exists ) folderObj.create();
};
function exportSFW( doc, saveFile, qty ) {
var exportOpts = new ExportOptionsSaveForWeb( );
exportOpts.format = SaveDocumentType.JPEG
exportOpts.includeProfile = true;//default false
exportOpts.quality = qty;
if ( saveFile.exists ) saveFile.remove( );
doc.exportDocument( saveFile, ExportType.SAVEFORWEB, exportOpts );
};
// make a new folder object from the doc path and change the structure from to-do to done. Note the folder being replace should not the doc path.parent
// S:\to do\folderA\subfolder36 to S:\done\folderA\subfolder36 not S:\to do\folderA\subfolder36 to S:\to do\folderA\subfolder37
var strPath = decodeURI( app.activeDocument.path );
strPath = strPath.replace( 'work', 'ret');
//strPath = strPath+'-retouched';
//strPath = strPath.replace(/\/.{3}\//, '/' );// will remove the first three char folder in the path
var saveFolder = new Folder( strPath )
createFolder( saveFolder );
var saveName = decodeURI(app.activeDocument.name);
saveName.match(/(.*)(\.[^\.]+)/) ? saveName = saveName.match(/(.*)(\.[^\.]+)/):saveName = [saveName, saveName];
var saveFile = new File( saveFolder + '/' + saveName[1] + '.jpg' );
// do your save for web step here using saveFile
exportSFW( app.activeDocument, saveFile, 80 );
Code: Select allfunction createFolder( folderObj ){
if( !folderObj.parent.exists ) createFolder( folderObj.parent );
if( !folderObj.exists ) folderObj.create();
};
function exportSFW( doc, saveFile, qty ) {
var exportOpts = new ExportOptionsSaveForWeb( );
exportOpts.format = SaveDocumentType.JPEG
exportOpts.includeProfile = true;//default false
exportOpts.quality = qty;
if ( saveFile.exists ) saveFile.remove( );
doc.exportDocument( saveFile, ExportType.SAVEFORWEB, exportOpts );
};
// make a new folder object from the doc path and change the structure from to-do to done. Note the folder being replace should not the doc path.parent
// S:\to do\folderA\subfolder36 to S:\done\folderA\subfolder36 not S:\to do\folderA\subfolder36 to S:\to do\folderA\subfolder37
var strPath = decodeURI( app.activeDocument.path );
strPath = strPath.replace( 'work', 'ret');
//strPath = strPath+'-retouched';
//strPath = strPath.replace(/\/.{3}\//, '/' );// will remove the first three char folder in the path
var saveFolder = new Folder( strPath )
createFolder( saveFolder );
var saveName = decodeURI(app.activeDocument.name);
saveName.match(/(.*)(\.[^\.]+)/) ? saveName = saveName.match(/(.*)(\.[^\.]+)/):saveName = [saveName, saveName];
var saveFile = new File( saveFolder + '/' + saveName[1] + '.jpg' );
// do your save for web step here using saveFile
exportSFW( app.activeDocument, saveFile, 80 );
-
karm
Exporting for the web, recreating folder structure
Thanks Mike it works perfectly !
I still have a problem when i launch the script on a folder containing special characters like é à. If you have an idea how to solve that...
I still have a problem when i launch the script on a folder containing special characters like é à. If you have an idea how to solve that...