Delete/remove/replace the files/folders during recording

Hello again.

I am a simple script similar to the one you have probably already seen and used more than probably before (multiexporter.jsx by Tom Byrne) finish. My production department asked that we give them one PDF file per the artboard in the document with the specific export settings and an appropriate filename (based on the name of the artboard).

I wrote a loop to save on each work plan with all the right settings... but now I'm on the problem of duplicates. It is very likely that I will have many names in double artboard, but they all need to be saved. By default, the files are overwritten by subsequent backup function. I spent that by adding a kind of number sequence at the end of the file name if a duplicate is found.

The problem is now, I want the script runs correctly, regardless of whether or not the destination folder exists. For example, I have already run the script and saved my file .ai and PDF files. Now I realize that I had to make a change in the file and re - register (via script) and overwrite the files that I saved it the first time. Unfortunately, due to the sequence of numbers that I talked about above, I get all the old files, but also all of the new files in the folder.

My first thought was to delete the destination folder and re-create. However, it seems that Javascript cannot do this. Should I just tell my artists that they must manually delete their records before they re - run the script? or is it possible to replace the folder while keeping the sequencing of files in the folder?

Here is the code:

#target Illustrator


//Script name: Save Document and Extract PDFs
//Author: William Dowling
//Creation Date: 10/15/15
/*
    Saves active document to user's desktop in dated folder with order number as filename.
    Saves each artboard as a PDF with artboard name as filename.
*/


function container(){
    var docRef = app.activeDocument;
    var layers = docRef.layers;
    var aB = docRef.artboards;
    var dest = findDest();
    var date = getDate();
    
    function findDest(){
        var dest = new Folder("~/Desktop" + "/Today's Orders");
        return dest.fsName;
    }
    
    function getDate(){
            var today = new Date();
            var dd = today.getDate();
            var mm = today.getMonth()+1;
            var yyyy = today.getYear();
            var yy = yyyy-100;


            if(dd<10) {
                dd='0'+dd
            } 
            if(mm<10) {
                mm='0'+mm
            } 
            return mm+'.'+dd+'.'+yy;
        }
    
    dest = "/Volumes/Macintosh HD" + dest + " " + date;
    if(!dest.exists){
        var newFolder = new Folder(dest);
        newFolder.create();
    }
    if(docRef.name.substring(0,2) == "Un"){
        var oN = prompt("Enter Order Number", "1234567");
        var fileName = oN;
    }
    else{
        var fileName = docRef.name;
    }
    var saveFile = new File(dest + "/" + fileName);
    if(saveFile.exists){
        if(!confirm("This File already exists.. Do you want to overwrite?", false, "Overwrite file?")){
            return;
        }
    }
    docRef.saveAs(saveFile);
    var pdfdest = dest + "/" + fileName.substring(0,fileName.indexOf(".ai")) + "_PDFs";
    var pdfFolder = new Folder(pdfdest);
    if(!pdfFolder.exists){
        pdfFolder.create();
    }
    else if(pdfFolder.exists){
        if(!confirm("The PDFs folder for this order already exists.. Do you want to overwrite?", false, "Overwrite PDFs Folder?")){
            return;
        }
        else{ 
            //pdfFolder.Delete(); //within this else statement, i'd like to remove the folder or it's contents and start with a fresh folder
            pdfFolder = new Folder(pdfdest);
            pdfFolder.create();
        }
    }
    
    //loop artboards to save individual PDFs
    
    var pdfSaveOpts = new PDFSaveOptions();
    pdfSaveOpts.preserveEditability = false;
    pdfSaveOpts.viewAfterSaving = false;
    var seq = 1;


    for(var a=0;a<aB.length;a++){
        var range = (a+1).toString();
        pdfSaveOpts.artboardRange = range;
        var pdfFile = new File(pdfdest + "/" + aB[a].name);
        var thisPDF = new File(pdfFile + ".pdf");
        if(thisPDF.exists){
            thisPDF = new File(pdfFile + " " + seq.toString());
            docRef.saveAs(thisPDF, pdfSaveOpts);
            seq++;
        }
        else{
            docRef.saveAs(pdfFile, pdfSaveOpts);
        }
    }
}
container();

I just did a test, and Yes, it looks that you must first delete all the stuff in the folder. the remove() method returns a true or false value, so you can check if the file could be deleted or not.

Tags: Illustrator

Similar Questions

  • where are the audio files stored during recording as a project?

    Where are the audio files stored during recording as a project. The project opens fine on my computer, but when I move to another computer I have missing audio files.

    They are stored in their own folder in the project folder:

    So if you want to move it to another computer, you must copy the project folder, not only of the project folder.

  • I'm not able to delete some of the files or some of the bookmarks in my favorites!

    I tried to delete/clear with the built-in library, this is the way that fails. It's strange, I can rename and replace the files, but I'm not able to get rid of them. I even installed Xmarks. When I remove the Xmarks, desappears file folder, but only in Xmarks, even after syncing with Xmarks.

    I'm despareted...

    Have you tried to delete the places.sqlite* files in case there is a problem?

    The file must have 2265 bookmarks, including folders and separators.

    See also this forum thread mozillaZine on playback of the files "jsonlz4": bookmarkbackup

  • How to speed up the removal of the files?

    Original title: search search index indexing re-indexing re-index research research research service troubleshooting troubleshooting

    In windows 7 Professional 64-bit. How to speed up the removal of the files. It takes 1.5 to 3.5 minutes to remove a file

    Before I give you a sensible answer in the following paragraphs, why don't you try not to create a new admin user account & try that.  I have absolutely no logic behind this suggestion, it's just that I've seen some strange symptoms in the other forum posts that have later been attributed to user profile problems and the test would take less than the time of deleting a single file without talking about relocation.

    Resettlement is a pain in the neck, so anything that resolves things without this point is worth.  Mine took me several days more sorting over several problems of McAfee.

    If the Dell disk is labeled 'réinstallation DVD' then he will do what is necessary because this is a full version of a Windows DVD installation [this is also what I have for them and that I used recently to reinstall from scratch].  Anyway, boot it from the disc only is not a destructive or dangerous act then you might try & see if the menus & options for the "repair installation" appear or not.  Just escape before you tell it to do anything then use again when you've prepared everything [backups, etc.].

    Your safe mode test confirms that Windows is at fault and not a third-party on your PC application.  The result of the safe mode is in fact a good result because this means that when you set Windows & malicious programs, you should be fine.

    Using the SpiritX AV cleaning tips will help you see if the malware is what corrupted Windows or if Windows comes to decide absolutely bloody & wreck itself.  If it is malware, so you still need to clean things up before the relocation to ensure that malicious software fails to cling to something during this relocation [I am simply repeating SpiritX here as I know nothing].

    It occurs to me that this Exchange did not once mention the Dell Factory Image Restore Partition.  This procedure is a little easier than relocation complete & it preserves the Dell-bundled utilties.  This is in essence an automatic & custom reinstall.  Before you begin this or even nothing else, in which case Dell did he not bring to your attention, you might not realize that Dell DataSafe Local Backup has a facility to make a USB / backup DVDR the Dell Factory restore partition .  This means you would retain the possibility to make a Dell factory restore in the future what you did with the hard drive in the meantime.  A disadvantage is that it would permanently replace the partitions that you have set up yourself [for Windows XP Mode or any other purpose] it really means return to the State wherever it was when you first opened the box.  My factory restore USB is 6.4 GB [Home Premium x 64 edition], but yours could be bigger - they advised me to use a 16 GB USB DRIVE as it was the size of the partition itself, then you can check the size to decide what USB can be required.

    I noticed that you talked to start in F8 for the repair menu or using a boot of the system repair disc. I guess you tried or had Dell try this for you.

    Good luck & patience.

  • I am currently using Windows Vista. I face a problem that I can't remove all the files in the form of MPEG-4. Error with code 0x800704C8.

    I am currently using Windows vista. I face a problem that I can't remove all the files in the form of MPEG-4. And the error with code 0x800704C8. What should I do so that I can delete these files? Please kindly help me to solve this problem. Thank you.

    original title: Code 0x800704C8...

    Hello

    Did you change your computer?

    Method 1:

    Step 1:

    I suggest you follow the link and check.

    What are the permissions?

    http://Windows.Microsoft.com/en-us/Windows-Vista/what-are-permissions

    Step 2;

    Why can't I delete a file or a folder?

    http://Windows.Microsoft.com/en-us/Windows-Vista/why-cant-I-delete-a-file-or-folder

    Diagnose and repair Windows files and folders problems automatically

    http://support.Microsoft.com/mats/windows_file_and_folder_diag/

    Method 2:

    I suggest to download and install the Microsoft safety scanner and run the scan and check.

    http://www.Microsoft.com/security/scanner/en-us/default.aspx

    WARNING: There could be a loss of data while performing an analysis using the Microsoft safety scanner to eliminate viruses as appropriate

  • How to identify files that may be deleted without jeprodizing the files needed to run the system?

    How to identify files that may be deleted without jeprodizing the files needed to run the system?

    If you have to ask, the answer is "Don't '.  Uninstall programs that you don't need through programs and features or add/remove programs.  Do not, under any circumstances, remove files unless you are absolutely sure you know what you delete first to 100%.

  • How to block a standered user to remove & copy the file

    Hello Sir

    How to block a standard user to delete and copy the file to the disc.
    I just let it open & watch... (do not copy & delete any file)

    Thank you
    with warm
    Vikash

    It's very difficult to do on a stand-alone computer.  You can use folder/file permissions (NTFS) rights to deny the ability of the user to remove.  Prevent copying is a more serious problem.

  • How can I remove all the files from adobe?

    How can I remove all THE files from Adobe? Including apps, preferences and all folders containing old items. Thank you!

    Use of the Adobe Creative Cloud cleaning tool to solve installation problems can help

  • Replace the file in Thinapp

    Hi all

    I have an application that uses a microsoft access database. I thinapp had this application and it works perfectly. However, on our physical machines, we replace the file with a new copy database whenever the user connects, because we don't want this database to grow. In the thinapp application, it is saved in % ProgramFilesDir %.

    Is there a way to do this in Thinapp? I'd hate to set up an image of parent separated for this application.

    Thank you

    Mike

    You can try to set REMOVESANDBOXONEXIT = 1 in the package.ini. The sandbox will be deleted when the user closes the application and once again created (with the database file) fresh at each time at the launch of the application. You may lose any customizations that are saved on the sandbox.

  • Cant unninstall lightroom 5.4 required to install update 5.5, I remove all the files and registry, but install fails

    Cant unninstall lightroom 5.4 necessary to install update 5.5, I remove all the files and the registry, but installation fails again and again, now I can't use lightrrom... Grins.

    I use the SSD drive and I can't have a lot of file uninstal (often having to clean disk)

    Thanks for help

    Hello Jeff,.

    Thank you very much for your reply, I use windows 8.1! I found the problem: to install the new version installation needs the program old installation (but I have remove all the installer, because they use a place a lot on hard drive (SSD)).

    I have uninstall all Adobe and reinstalled, I save the full installer on an external drive. When the installer asked the former installer I indicate to programm my drive external and everything works fine now.

    Thanks so much for your help, I just do not delete the old file (sad having to save old installler just to install the new).

    Wallie

    (Sorry my English)

  • Give permission to the domain users to replace the file in the folder created by domain admin

    We have a domain controller in our network. also we have the domain users and domain administrator. We create a batch file that copies a file to the folder by using a script to the server policy when users open a session input/output. However if the admin area access system cant use overwrite file in the folder. We want to give permission to the domain users to replace the file in the folder created by the domain administrator.

    Hello

    The question you posted would be better suited in the TechNet Forums. I would recommend posting your query in the TechNet Forums.

    http://social.technet.Microsoft.com/forums/en/category/w7itpro, w8itpro, windowsvistaitpro, windowsxpitpro, windowsintune

    Hope the information is useful.

  • Organize the files/folders alphabetically in vista

    How to organize the files/folders (in the personal / folder documets) alphabetically in Vista?

    Hello

    'organisation' is in the visualization

    Start - computer OR Windows Explorer

    Click the arrow to the right of the VIEW - set for details drop-down (you can use other it is just easier to see details)

    then click the column name in the pane on the right to a - Z and click again to Z - A

    Click the v arrow down to the far right of the title bar of the column name for more options.

    I hope this helps.
    Rob - bicycle - Mark Twain said it is good.

  • Delete all the files/folders of old install once the last series on the window updates have been installed?

    I have everything, if records of installation/uninstallation and newspapers since I installed XP.

    I'm sure that the last set of Windows updates work.

    Is there a problem with the removal of old files/flies and connects using CCleaner?

    If not all, can I at least remove those older files that the SP2 install date?

    What problems can I hire after cleaned?

    I guess that the answer to MS Office updates also apply.

    Thank you

    caveman88

    If your PC behaves properly, you can remove the hidden Windows hotfix backup files that start with $NTUninstallKB to the WINDOWS folder. There are two ways to do:

    A. manually, but copy files on a CD/DVD first to enable their restoration has a fix must be removed thereafter. Now delete the folder \WINDOWS, but leaves the orphan entries to add / remove programs intact. Remove only the $NTUninstallKB files that relate to corrections, not those for applications such as Word, WMP, etc.. In addition, DO NOT DELETE THE folder$ $hf_mig.

    B. my preference goes to run a script that also removes the corresponding entries in Add / Remove programs. Once they are deleted by the script, they cannot be restored. Download, extract and run this little scripthttp://www.dougknox.com/xp/utils/xp_hotfix_backup.htm creating a system restore point first just in case something goes wrong when the update of the register.

  • Need help to save the files/folders to a backup disc to record on a newly installed hard drive, which is totally empty.

    Last year I had everything (files, documents, photos, etc.) in my computer saved on a CD. My computer crashed last week and held our Geek Squad 'doctor '. The hard drive has been replaced, and I need to transfer or copy from the backup drive saved on my computer recently recommended. Can you please explain how to copy all my files/folders on my computer? Help!

    Last year I had everything (files, documents, photos, etc.) in my computer saved on a CD. My computer crashed last week and held our Geek Squad 'doctor '. The hard drive has been replaced, and I need to transfer or copy from the backup drive saved on my computer recently recommended. Can you please explain how to copy all my files/folders on my computer? Help!

    ================================================
    You were previously running Windows XP?

    You're still using Windows XP?

    How was created the backup CD?

    If you insert the CD in your CD drive and go to...
    Start / Workstation... and right click on the drive
    Letter it displays the directory for this drive...
    the CD? If_Yes_ what are the files names which
    you do not see?

    If it was just a simple data CD... you can copy.
    Paste the files in a folder on your hard drive.

  • Removal of the protected folders

    Hi, when I replaced a hard to die, I saved the folder "program files (x 86)" on my desktop. I have now deleted all that I needed him and wants to remove it. I managed to delete all the files in the folder and subfolders, but I can't delete the folders themselves. I've updated my permissions so that I have full control and I signed up as an administrator on my computer, which is not on a network. I was able to rename the files, but when I try to delete them, it always says that I need the permission of the administrator. What can I do? Thank you!

    The next thing you should try is to take ownership of this tree of files/folders.  By default, administrators are granted the privilege "TakeOwnership", so while logged on as administrator, open a command prompt window high as before.  When he arrives, try to take possession of these files by using the following command:

    takeown /F C:\Users\quartet1977\Desktop\fluffy/a/r

    The above command will [should] attribute ownership of the entire tree to the Administrators group.  Once you have the property, as an administrator user, you should be able to grant access to records:

    ICACLS C:\Users\quartet1977\Desktop\fluffy/grant Administrators: F/t/c

    Then after that, you should be able to delete the files.

    If 'takeown' complains that you do not have privilege, then you should check to ensure that administrators have the privilege "TakeOwnership"...   From a command prompt, type:

    gpedit.msc

    When appears in the Group Policy Editor, navigate to:

    Local computer policy-> Computer Configuration-> Windows settings-> security settings->

    Local policies-> user rights assignment

    and in the right pane, look for 'Take ownership of files or other objects' and check that this privilege is assigned to the "Administrators".

    HTH,

    JW

Maybe you are looking for

  • png image does not open in Firefox (wants to download)

    This is one of those little annoying things. I enjoy working the Samarai. available from djape Sudoku puzzles. Solutions for all the different puzzles are available on a single page: http://www.djape.net/sudoku/wp/index.php/solutions/ For puzzles, I

  • Printer driver is missing

    I was printing on my HP printer very well. All of a sudden, it has disappeared from my printers folder. I can't print from Word or email. When I select print in my e-mail address, it is not said "no available printer drivers" and will not let me cont

  • How to get the PIN NUMBER in decimal format?

    I was wondering if there was a way to get the PIN device in decimal?

  • Windows 7 build 7601 error message

    Diagnostic report (1.9.0027.0):-----------------------------------------Validation of Windows data--> Validation code: 50Code of Validation caching online: 0xc004c4abWindows product key: *-* - GJY49 - VJBQ7-HYRR2Windows product key hash: W5/6nm6F2UPX

  • BlackBerry Smartphones Facebook 1.6 for blackberry 8700 v

    I have an 8700 and because it uses a wheel track I can't in my opinion.  I want to go back to v 1.5 anyone knows where I can, cause I have all these facebook notifications that do not go far.  Here they will realize that Blackberry with trackwheels n