Save the file with the same name

How to change the script to save the file with the same name?






//SaveforWebSP.jsx  



//Save a fixed width image with a size constraint in its original folder  


 
 



var docRef = activeDocument;  



var outputFolder = docRef.path;  


 
 



NamesaveRef = new File( outputFolder + "/reference.jpg" );  



var NewfileRef = new File( NamesaveRef )  


 
 



// quality/size constraints  



var w = 1920; // new file width  



var MaxSz =  361440; // max. 360Kb  



var Qlt = 100; // initial quality 100  



var x = 1; // decreasing step  


 
 



// resize the image to the right width  



docRef.resizeImage(UnitValue(w,"px"),null,100,ResampleMethod.BICUBICSHARPER);  


 
 



// Perform the first SaveForWeb Operation  



ExpWeb(NewfileRef, Qlt);  


 
 



// Keep trying to save the file with max. Qlt, but under MaxSz 
 



while (NewfileRef.length > MaxSz)  



{  


      
Qlt = Qlt - x;  


      
NewfileRef = new File( NewfileRef );
 


      
NewfileRef.remove();  


      
ExpWeb(NewfileRef, Qlt);  // Perform a new SaveForWeb Operation, with slightly lower Qlt  


         
if (Qlt <= 40) {  


           
alert("The file can't be saved with the desired size AND quality.");  


           
break  // break the loop whenever the quality is as low as 50 (this shouldn't need to happen)  


         
}  



}  


 
 



var FileSz = NewfileRef.length/1024;  



FileSz = Math.round(FileSz);  


 
 



// close the original file without saving  



activeDocument.close(SaveOptions.DONOTSAVECHANGES);  


 
 



// SaveForWeb Export, with the desired constraints and parameters  



function ExpWeb(FileNm, Qlt)  



{  


      
var options = new ExportOptionsSaveForWeb();  


      
options.quality = Qlt;   // Start with highest quality (biggest file).  


      
options.format = SaveDocumentType.JPEG;   // Save Format for the file  


      
docRef.exportDocument(File(FileNm), ExportType.SAVEFORWEB, options);  



} 




Change of line 25 to:

 var docName = docRef.name.split('.')[0];
 NamesaveRef = new File( outputFolder + "/"+docName +".jpg");

Tags: Photoshop

Similar Questions

  • where to save the files under options the file name is duplicated how to remove an additional folder with the same name

    Under Options in Firefox, I clicked on save the files under downloads, but the file name twice and an additional file with the same name is created in the folder, i.e.:

    G:\Akbar's Songs\HAMARA DOWNLOADS\HAMARA FORUMS DOWNLOADS FORUMS

    As you can see the file repeats, how can I fix it?

    Also the music files, I download from a site of downloads as a WinRar file and I need to open it. Y at - it an option where the file opens automatically in the folder I chose?

    Thanks a lot for your help.

    Hi Akush, when you install 7 - zip, make itself the default application to open .zip and .rar files. So if you double click on the .rar file, it should open in 7 - zip. If you prefer to decompress immediately, right click the file and look for new 7 - zip items in the menu. I can't think of a way to do this automatically, however.

  • 2 separated registered photos with the same name of file/number.

    How can I separate 2 or more photos with the same name of file/number. Consult us in the case that I see a photo and when I open it I see a different picture. The second photo is not the case in the folder, but still I need to save. It seems they are crushed.

    How can I separate 2 or more photos with the same name of file/number. Consult us in the case that I see a photo and when I open it I see a different picture. The second photo is not the case in the folder, but still I need to save. It seems they are crushed.

    =============================================
    FWIW... If a picture was crushed (replaced), it is unrecoverable.

    Are you saying that the vignette does not match the full size photo?

    How_exactly_are you look at one picture?

    John Inzer - MS - MVP - Digital Media Experience - Notice_This is not tech support_I'm volunteer - Solutions that work for me may not work for you - * proceed at your own risk *.

  • Replace the files with the same name - crush

    Everytime I go to save a file (in the office) for example, if this file has the same name with another in the save destination I'm asked if I want to replace it with one that I am saving at this time.

    I push the button no and I choose a different name for the file.

    What I want is this:

    If the file has the same name I want to be saved anyway, and in his name a number is added which means that it is another file.

    ex, jane, and jane (1)

    I want the 1 are added automatically. I noticed these when I save a file after scanning a document using the windows fax and scan feature.

    How do I develop the functionality usually precedes for windows.

    It is something specific to the program. The notebook is not programmed in this way.
     
    --
    ..
    --
    "JimVag" wrote in message news: b2bb4770-bd85-44b9-987b-33ccbd4c3dd0...
    > Everytime I go to save a file (in the office) for example, if this file has
    > the same name with another in the save destination I was asked if I
    > want to replace it with one that I am saving at this time.
    >
    > I don't press the button no and I choose a different name for the file.
    >
    >
    >
    > What I want is the following:
    >
    > If the file has the same name I want to be saved anyway, and in his name a
    > number is added, which means that it is another file.
    >
    > ex, jane, and jane (1)
    >
    > I want the 1 are added automatically. I noticed this when I'm
    > saving a file after scanning a document using the Windows and scan fax
    > feature.
    >
    > How am I going to extend the feature generally above for windows.
    >
    >
    >
    >
    >
     
     
  • I can't save a PDF with the same name

    I can't save pdf files with the same name on the network drive in our society. I have full control over this network drive and can do anything create/read/write/change. Other programs work fine, but not Adobe Reader. I can save a pdf file with a different name, but when I try to save as in XI or replace as in DC had an error: the file is read-only or opened by someone else. Save the document under a different name or in a different folder.

    By the way, Acrobat Pro, I got the same message.

    reader_error.png

    Hi igorp74028164,

    Please provide the exact point of the software & OS installed on your system. Also check if it is there any update available for the software after crossing "" help > check updates "»

    Follow this thread to reset the preferences for the acrobat software. : - How to reset preference settings in Acrobat format.

    Also please check if this file is saved to the network drive or local, if its network on Please save it on local disk & then check. Make sure also that this preview pane must be closed in windows Explorer.

    Kind regards

    Christian

  • My goal: "convert to pdf"-&gt; the file is saved with the same name as pdf instantly. feasible?

    Hello dear experts

    I use Adobe Acrobat 9 pro extend to convert word, ppt, jepgs etc. in a PDF file.

    Not if I

    (1) convert a ppt in pdf: he asks-> "save under"-> converts--> opens the file

    (2) convert a JPEG to PDF: it opens instantly-> file in pdf-> I need to save manual under "save under".

    In both cases, I want to

    My goal: "convert to pdf"-> the file is saved with the same name in pdf instantly

    WITHOUT asking me "save under" + "opening the file.

    Is possible and if so, how DO ?

    A fast response is very very much appreciated, because I need to convert hundreds of files this evening in order to get into 1 pdf

    THX and greetings from the Germany,

    Julia

    Try the forum for Adobe Acrobat.

  • [.ini files] Get the value of multiple labels with the same name

    Hello!

    In an ini.files, I need to get the value of each tag named in a certain way in a section, but unfortunately, I have 3 or 4 tags with the same name in several sections. I don't know how to retrieve these values, the program always consider that the first tag and not others, I tried to remove each tag after obtaining its values, that he did not.

    Does anyone have an idea to solve the problem?

    Thank you!

    As you can read in my last post, you must read and throw 'x' lines:

    OpenFile)

    Skip lines

    for (i = 0; i< x;="" i++)="" readline="">

    Start reading the useful lines

    ReadLine () / / read a line

    ... / / Interpret the line

    Don't forget to add a control during i/o operations of robust error and to check the end of the file.

  • I want to copy all my jpg files to another directory (a portable hard drive) with some of the same names of JPGs, but not necessarily all. What will happen? The word 'COPY', will be some of the deleted files be added or nothing at all.

    I have a LOT of pictures in my computer (over a thousand) and I want to put them on a portable hard drive, I bought (1 terabyte) but I won't write any of the names of existing files with different images. IS THIS POSSIBLE? Do I need software or special hardware? I tried the copy/paste standard as well as move files to the new directory, but it seems that I can lose files. I'm not sure if the files that are missing (or lack, in my opinion) are not copied. When I finished emptying the directory, it shows that it is empty but the new directory does not seem to have any additional files that should be there based on the counting of the files before and after.

    Thanks for any help you can provide, Bill

    1: right-click and then drag the pix on the external drive. Release the right mouse button and choose copy here. They are there?  Now remove it from the computer.

    2: you can see pix of the same name overwrite each other, or be done with (1), (2), etc.. But even in this case, they will be interspersed with the former. If keep you them in separate folders with different names, that should not happen. Personally, I rename all the pix before storing them. You can select the set instead of the code of the camera and a group, rename the first holiday 2009 yo and the rest will be renamed holiday 2009 and each havf will one (1), (2), (3), after them.

    It is also a nice freeware tool which, among other things, can rename a group of photos easily.

    FastStone Image Viewer
    http://www.FastStone.org/

    Bruce Hagen
    MS - MVP October 1, 2004 ~ September 30, 2010
    Imperial Beach, CA

  • Renaming of files exe with the same name

    I have

    just installed a game on steam.  The package ended up being buggy, so it did not work.  But I found a solution on the Forum and he told me to rename these two files exe under the same name.  Its the only way to fix the game.  Others did and cela worked.  When I try to rename the file an error pops up telling me that I can't have two files with the same name.  In summary, this is what is happening.

    two files are: prince of persia.exe and princeofpersia_launcher.exe .

    Need to rename it to princeofpersia_launcher.exe to the prince of persia.exe

    An error pops up saying ERROR RENAME FILE or FOLDER: cannot rename princeofpersia_launcher: a file with the specified name already exists.  Specify a different file name.

    The problem is that these two exe files MUST have the name of prince of Persia: work.  Is it possible that I could do?

    It is not possible to have two files with the same name in the same folder.  Something is wrong with the instructions that you try to follow.  What do say exactly?  Can you give us a link for them?
    Boulder computer Maven
    Most Microsoft Valuable Professional

  • Files and folders with the same name

    I am trying to unzip some files and folders and it works fine on my computer with Windows XP. However, when you use Windows Vista I can't because there are folders and files with the same name. After an internet search, it seems that the only suggestion is to extract the files in separate folders which then would allow them to keep the same name. The problem is I want what they in the same folder and they need to have the names they have.

    NOTE: I do have two files with the same name in the same folder, I have a folder and a file with the same name. I would have thought that this would be acceptable because they are two things separate, and given that it's great under XP.

    All solutions?

    You are right, if I make a file and a text file with the same name, it works fine. However, when I try to extract the files I need it tells me that there is already a file with the same name as the folder. He goes to tell me to choose a new name but my only options are 'try again', 'jump' or 'Cancel '.

    I think I can understand what the problem is. For some reason when you download the zip file, the computer seems to have added a few files side with any format other than "file." It is those who have the same name as the folders as if they were, and they could not be uncompressed because of this. I have no idea whence they came as they appear from nowhere (compared to my XP). I'm trying now unzip the files separately and exclude the strange s 'file '.

    Thanks for your help though!

  • DISABLE "there is already a file with the same name to this place.

    Window 7. 64 bit. How do you turn OFF DISABLE, CANCEL, DELETE, STOP the pop-up 'MOVE the FILE'?

    As a user since the days of DOS command lines and having had a routine all the way through to XP, this new window is one of the most annoying pop ups for an experienced user. If it isn't a swith toggle check box or an other power selection for this message, there must be. And if there is, you did it quite hard to find.

    The dialog box that appears in Windows 7 that starts with "there is already a file with the same name to this place. It lists then the three choices - "Copy and replace", "Do not copy" and "copy, but keep both files.

    I managed several libraries of forms which oblige me to replace the files throughout my day. I make a copy of the file I replace first of all, for archival purposes and this pop-up box is, well, it's boring. There must be a way to disable.

    This box comes up to move files and to copy the files.

    Any help in these turn off would be appreciated.

    See you soon.

  • Several files with the same name.

    Cannot publish to Business Catalyst because of a fatal error, where it is said "why do we have several files with the same name?  The website and all its contents have not changed in more than a year with the exception of minor changes to the wording so unable to understand what the error is encountered. Are there not better misdiagnosed at one point less for the files in question.

    The problem is the result of a mixture of case-sensitive and case-insensitive between how files within the .oam are put into interaction with and what is written in the muse_manifest.xml file during a re - download full compared to an incremental download.

    If all .oam packages files are tiny and the original .oam were replaced in Muse with the all new tiny .oams, then you should select Upload: publish all the files in the dialog box Options. From there, forward publication of incremental changes should work without errors.

  • Return of the mistake of MUSE: why do we not have several files with the same name?

    Well - I thought I had all this worked and fixed, but I met the download error 'Why do we have several files with the same name' once again.  (I downloaded all the files several times today in order to 1) works the way it worked the last time and 2) get an OAM file that is not loading for some reason any load again and the download takes about an hour to transfer all the files manually.

    To recap:

    (1) an option "Upload only modified files" returns the 'Muse has encountered an error and closes.  Why do we have several files with the same name? "error just as before.

    (2) a full download will work but takes forever and is NOT a substitution for work changed files option.

    Please advise with possible solutions!

    -Dave

    Is it possible to have two .oam different files in different folders on your computer where the .oam files have the same name? I'm theorizing that there may be a bug in the treatment to ensure the folder created for a .oam placed on the server receives a unique name, particularly in the case of a partial update of the site on the server.

    Please send us the .muse file and all the files in .oam related to [email protected] along with a link to this topic for the context so we can attempt to reproduce this error and isolate the root cause. If files are larger than 20 MB, you'll need to use a service such as Adobe send & Track, Dropbox, creative cloud, WeTransfer, etc. file sharing. Thank you.

  • Help! Need a script to automatically open files with the same name but in another location.

    Good morning friends,

    So for my work, I need a script to open files with the same name but located in a different folder. But since I'm a total noob when it comes to programming, I can't understand how do. That's what I have in mind:

    -J' I manually open an image.

    -The script will look for a file with the same name in another folder that I've specified.

    -The script will then select the channel CMYK of the second file and copy and paste it into the first file.

    -The second file is then closed without saving the changes.

    I have problems with the part where the script searches for a file with the same name as the opened file. I would really appreciate help. Thanks in advance.

    If (app.documents.length > 0) {}

    myDocument var = app.activeDocument;

    var Nomdoc = myDocument.name;

    try {var basename = docName.match (/(.*)-.)} [ ^\.] +$/)[1]}

    catch (e) {var basename = thedoc.name};

    var path = / * path of folder to insert as a string here * / + ' / ' + base name + / * insert file extension, including the period as a string here * /;

    If (queue (path) .exists == true) {var otherDocument = app.open (File (path))};

    };

  • Server data store will automatically get updated when the new file (with the same name) is placed in the landing area


    Hi guys,.

    The data store server-side will get automatically updated when a new file with the same name is loaded in the landing area?

    for example

    1 data store created for server-side get the file named UK.xls (he has 5 rows)

    2 snapshot created for the above data store

    3. created with the snapshot process

    After that if I remove 2 lines from the same file and load again to the landing (with the same name). So by re-running the process will take the last file OR do I need to reload the file in the data store every time when there is a change in the file. We also tried with option to work but the last file was not picking up.

    Any help will be really appreciated.

    Please lets us know your updates.

    Please advice

    Thank you

    VT

    Hello

    When you create a snapshot, you create a snapshot whose task (provided that you use a data store server-side) can be run from a job. To refresh the data, run the snapshot in a job task. If you create a task at the time the snapshot and the processes that use it, they will automatically connect and will be 'upstream' data through the snapshot in the process. You can then choose whether it would be appropriate to write the snapshot or not (for the effectiveness of performance if you want to do the straight through processing) by activating or deactivating the bucket of data staged that the snapshot written to. The snapshot in the work task means that the data is refreshed.

    For the work of design to the Director, you can refresh the snapshot by running again it manually in the context menu.

    Kind regards

    Mike

Maybe you are looking for

  • How can I save my El Capitan for a boot drive?

    I want to just save El Capitan, because I have to do a clean install on her husband's computer?  How can I do this?  I try to get just a clean download from El Capitan but he won't on my memory stick

  • Driver error occurs when I try to write CD's to my Satellite Pro P200-1EE

    I had many problems with the HD-DVD playback after several updates of BIOS that I can now do that... so I'm trying to burn a CD and Vista comes up with an error of the pilot. When I go into the Device Manager, the driver installed on the disc is 2006

  • Quicken 2000

    Windows 7 won't boot my printer when you try to print Quicken 2000 files.  My previous operating system was Windows XP Home Edition and I had no problem printing from it.  What upgrade should I install to allow printing from Windows 7?

  • BlackBerry smartphones I want to retrieve my contacts.

    Hello world. I have a blackberry 9800. I have reset to the factory default, so my contact and my Inbox is empty now. I have no backup of them. Is there anything I can get my contacts. There are many crucial number in it. Thank you.

  • my sound cofiguration is incorrect

    I can't hear sound from my speakers, I changed my speakers, then also I cannot hear the sound when I downloaded iTunes, it shows my sound configuration is incorrect please help me fix my sound systems set up Mobile no.: