aFile.remove () does not not as expected

Trying to find out why the code below is not delete all the files in the target folder.

After some tests, it seems that the only graphic files (jpg, png, gif) are removed, jumping docx, eps, pdf, doc, txt, etc.

Have you seen what is happening before? Thank you

#target framemaker

var aGraphicFiles = [];

//Check for target folder existance, if not, create.
var myTargetFolder = new File("C:\\Basket2\\XML Tests\\BookFolder\\Resources\\DeleteMe");
if (!checkFolderExists(myTargetFolder)){ //target folder does not exist
    myTargetFolder = new Folder("C:\\Basket2\\XML Tests\\BookFolder\\Resources\\DeleteMe");
    myTargetFolder.create();
}

//Check if folder DeleteMe is empty
myTargetFolder = new Folder("C:\\Basket2\\XML Tests\\BookFolder\\Resources\\DeleteMe");
aGraphicFiles = myTargetFolder.getFiles();
if (aGraphicFiles.length != 0){
    for (i=0; i<aGraphicFiles.length; i++){ //scan array
        var sourceChild = aGraphicFiles[i];
        if (sourceChild instanceof File){
            sourceChild.remove();
            }
        if (sourceChild instanceof Folder){
            alert("I found a folder");
        }
    }
}

function checkFolderExists(myObj){
    var flagEx = false;
    if (myObj.exists){
        flagEx = true; //alert("myTargetFolder exists");
     } else {
        flagEx = false; //alert("myTargetFolder does NOT exist");
     }
     return flagEx;
}

Hi funsekon,

Here is an example, it works:

Unfortunately the editor does not accept code for time, so I put here in this way:

Just a few notes in your code:

It is easier to check if a file exists:

If (objfile.exists)...

The reason why your code does not work

Define an object file to remove/delete it. : sourceChild = new File(aGraphicFiles[i])

sourceChild.remove)

Your line 3:

var myTargetFolder = new File ("C:\\Basket2\\XML Tests\\BookFolder\\Resources\\DeleteMe");

should be

var myTargetFolder = new file ("C:\\Basket2\\XML Tests\\BookFolder\\Resources\\DeleteMe");

VAT: BE CARFUL WITH THIS SCRIPT - WILL FINALLY REMOVE ALL FILES!

var older = new Folder ("C:\\test\\deleteme");
var oStartFolder = oFolder.selectDlg ("select a file");
If (oStartFolder! = null)
{
DeleteFilesInFolder (oStartFolder);
}

function DeleteFilesInFolder (foFolderName)

{

var locError = false;
var DeleteFolder = New Folder (foFolderName)
var foFolderContent = DeleteFolder.getFiles (' ');
for (var i = 0; i)< fofoldercontent.length;="" i++)="">
{
If (foFolderContent [i] instanceof file)
{
var FileToDelete = new queue (foFolderContent [i]);
FileToDelete.remove ();
If (FileToDelete.error > "")
{
locError = true;
Alert ("error deleting file :") + FileToDelete.fsName;
}
}
}

}

Tags: Adobe FrameMaker

Similar Questions

  • Recently, the delete key and rt click on remove does not remove a message. Must restart you Bird to be able to delete a message. With the help of v 24.5.0

    Using Thunderbird 24.5.0, W7, patches up-to-date

    The DELETE key or right-click delete suddenly does not remove a messsage.

    Restart Thunderbird and then they both work.

    What should I look for?

    File is not very large and simply restart brought the function.

    But, as a note aside, I don't have the problem in the last two days.

    Don't know what has changed. However.

  • safely remove does not appear in the menu

    I'm trying to safely remove a file. But it does not appear in the finder menu. How can I proceed?

    How to delete files safely in OS X 10.11 "El Capitan."

    How to delete files safely in OS X 10.11 "El Capitan" (2)

  • PopUpManager.remove () does not work

    Hello

    I'm developing an application that uses instances of TitleWindow to display information. I had problems with pop - up in which clicking the 'closeButton' has that a noticeable effect, it no longer responds to drag events. It would be okay if the instance were not as visible. The popup is placed in a canvas container, don't know if it's hit or not. I finally managed to make this work, it is interesting by removing the < mx:Style > element of the main application mxml file. The complete code, using a smaller example, is attached. Any explanation would be greatly appreciated. Still more appreciated it's tips on getting in fact it works as I would that he (i.e., with the style).

    See you soon,.
    Rich

    Thanks to all for the replies. Turns out my problem have to do with setting incorrectly the parent of the pop-up window.

    In BrokenPopup.as, dragDropHandler(), instead of using the PopUpManager I ended up adding the new BrokenPopupComponent object as a child of the object Canvas container identified as 'popupCanvas' in BrokenPopup.mxml. Not sure why the original implementation did not work properly, but I want the popup to be a child of the canvas and PopUpManager does not appear to support.

    Once again, thank you for the answers.

    See you soon,.
    Rich

  • Filling of camera works does not as expected in Android OS 4.0

    Hi all

    Recently upgraded to Ice Cream Sandwich (Android 4.0) on my model of Motorola Xoom Wi - Fi. Love it so far. I seem to have a new problem trying to create a camera effect fill of any kind. Steps to repro:

    • Create any type of layer
    • Press on the '&' > type 'bridge camera '.
    • Try taking a picture; PS Edit then ends in a loop of treatment (with the four squares to the right animation)

    If I try to use the 'back' button Android, I can go back to the Android home screen, and then re - enter PS Touch, who then proceeds to ask me if I want to save my snapshot (which is basically empty). I type any option and everything goes as usual (less PS touch do not take the picture).

    I suspect it has to do with Ice Cream Sandwich and the new drivers for the camera of the Xoom. I tried uninstalling and reinstalling PS Touch that does not solve the problem.

    Other that that, I have not found something else wrong while using PS touch under Ice Cream Sandwich. I notice a very little bit of performance increase also.

    Just thought that I let you know and see if anyone else can repro.

    Version 1.1.1 fixes all my problems. Fonts are back, selections so that work now complete camera very well. Yay!

  • newText works does not as expected

    Hello all,.

    I am using formCalc.

    My form has a drop-down list box allows this custom text entry. On the change event is a script as follows:

    SubformRecap.TableLiabilityRecap.Row [13]. Cell [1] = xfa.event.newText

    The custom text entered only works when the user:

    • start typing without displaying the menu choices drop-down or completely erases the text of an unwanted choice field
    • then, type the custom text
    • AND then press ENTER

      The script fails to capture the newText if ONE of the following actions occurs

      • does not completely erase the contents of the field drop-down box
      • or highlights and types on the highlighted text
      • or, use TAB instead of ENTRY when you have finished typing

      When it fails the following text/integer appears in the referenced field: 1

      I have limited user so I guess I could train, however, I would like to avoid that if possible. It's a great form and TAB the norm for the entry and exit of the fields. People use it on their laptops in the field - oddities like this in order to have a major nuisance.

      Is the change the right event? Is there a way to enter (ENTER virtual) script?

      Thanks in advance!

      Stephen

      Well, this problem seems interesting... I tried to rebuild, but nothing never is, for me it works in any case so far.

    • Events in Subvi works does not as expected

      Hi, I'm reposting this question because my previous one did not lead to a satisfactory conclusion.

      I enclose my Vi which do not work as expected. If I remove a Subvi and its controls of 3 partners and two indicators, it works fine, but when I add two screws SUB, it's messy. I'm learning in this way, I don't know it can be done a lot of other ways, but please help me find the problem, do it this way in my final MainVi, I would use Live 8 such void. Thanks.

      Your main problem is the FLOW OF DATA.  A loop can not browse all what it has not completed.  So, as you have, you must have the two structures of event execture before you can go back to look for the next event.  So if you insist on having these subVIs, they must be in separate loops.

      BTW, you can get away with a single Subvi.  Go to the properties of VI and make incoming (preallocated clone).  Then, each call to your Subvi has its own memory space.  Much easier to maintain this mode.

      And I know you said you didn't want alternatives, but here's how you can do it with a unique structure in your main loop.

    • When you delete a file in Vista, the dialog box remove does not close until the computer is restarted

      When you delete a file in Windows Vista, the dialog box remove don't close until the computer is restarted. It is sometimes possible to remove it by closing tha task list. When this is done, the Explorer is closed and restarted.

      Hi Brian,.

      (1) since when are you facing this problem?

      (2) remember to make changes?

      Method 1: Run the fixit available in the link below and check if that makes a difference

      Difficulty of broken desktop shortcuts and common system maintenance tasks


      Note:
      Fixit would attempt to recover bad sectors on the hard disk, in the course of this process there are chances of data loss from that particular area.

      Method 2: If a Protection of resources Windows (WRP) file is missing or is damaged, Windows may not behave as expected. Auditor of file system (CFS) scan to fix all of the corrupted system files. To do this, follow the steps mentioned in the link below:

      How to use the System File Checker tool to resolve missing or damaged on Windows Vista or Windows system files

      http://support.Microsoft.com/kb/929833

      Method 3:  Select the boot and then check if the problem persists

      Follow step 1 in the link below,
      How to troubleshoot a problem by performing a clean boot in Windows Vista or in Windows 7

      Important: n ' forget not to put the computer to a normal startup follow step 7 in the link.

    • handheld at 1 pixel brush works does not as expected...

      Hello everyone :-)

      When I try to draw a simple freehandline with the tool draw we get this before I release the mouse button:

      Outline 1.jpg
      That's how I expect the line to be in the final drawing.

      But instead I get this so after releasing the mouse button:

      Outline 2.jpg

      I'm using this brush settings:

      Brush Settings.jpg

      So he must produce a solid rounded 1 pixel brush stroke... In Illustrator CS6 this worked as expected.

      What I am doing wrong? :-o

      All apreaciated advice! :-)


      Have a good day, cyan68

      "Einfach" means "without a brush.

      But: the Brush tool will not work without a brush, he always apply a brush.

      The pencil tool is what you want. Really.

      It works exactly like the Brush tool, but without having to apply a brush.

    • HP ENVY x 360: HP ENVY x 360 Win 8.1 battery plugged not removable, does not support

      HP dear supporters,

      I have a HP ENVY x 360 laptop with Win 8.1 operating system. He writes that plugged in, not charging. This laptop has a non-removable battery. I read the forums and advice but neither solved my problem.

      I tried to close, plug off, wait, plug in, turn on, without result.

      I also tried to uninstal in Device Manager the baterries, then restart the laptop, without result.

      I also tried the fix for the problem with HP Support Assistant, digitization of the battery and he writes that my battery is ok, but then "unknown".

      I tried to download updates, no results due to "unknown".

      I'm not able to solve the problem of my laptop and I wouldl ike to ask for your help.

      I await your response.

      Kind regards

      @zsofiaanna

      Thanks for posting,

      If none of the latest articles helped.

      The best thing you can do is to try with another adapter with the same power supply.

      If the problem persists with the other cable

      To confirm if it is the battery or adapter that is faulty,

      The information, handy - contact the HP support by phone for a repair or dispatch part service (as applicable).

      If the information I provided was useful, give us some reinforcements by clicking on the solution and laurels, buttons that help and others see that we have the answers!
      Good luck.

      HP technical support are available by clicking on the following link:

      http://h22207.www2.HP.com/us-en/?openCLC=true

      (1) once the page opens, please select the country in which you are located. Then enter your model of HP on the right number.

      (2) then choose "Contact the Support" tab at the top and scroll to the bottom of the page "HP Support - contact" to fill out the form with your details.

      (3) Once finished, click the "Show Options" at the bottom right.

      (4) Finally, scroll to the bottom of the page and select "Get a phone number." A file number and telephone number will now fill for you.

    • Poster works does not as expected with Adobe CS5

      I've finally updated to OS X on an early 2009 Mac Pro Quad Core. I have two screens: a 20 "Apple Cinema and a Samsung Syncmaster. Previously, always with Snow Leopard, I had no problem with the implementation of my menus, panels, etc on the Samsung, thus leaving my film clean and only to view the picture or painting under development. It's a great ploy.

      But now, I can't have my workspace (menus, panels and so on) to "stick" to the Samsung. Instead, they insist on layering anything I'm working on the cinema, which is now difficult to see behind all the clutter menus and panels.

      I tried to move this to the Samsung, and I saved the arrangement as a new workspace. But the next time and so on, I opened Photoshop, all the menus were back on my film. It is a problem, I expected little, all the problems you may have. But it is serious because I'm not keen on having to pass all the other screen before starting work. In addition, it could be the cause? None of the existing workspaces or those custom made displays on the second monitor except if moved manually.

      I'd appreciate responses as to why this is happening. Thank you

      -Try to reset memory NVRAM/PRAM and SMC

      MacIntel: Reset of the controller (SMC) system management

    • T440: m.2 speed NGFF SSD does not as expected

      Hello world

      I bought the 128 GB model of the MyDigitalSSD Super Cache 2 (see here). Write speeds are as expected, about 170 - 190 MB/s. However, the playback speed is capped at 270 MB/s, although it should reach well above 400 MB/s. It is confusing to me. I installed the SSD m.2 in the same location where the original cache my T440 (16 GB, SanDisk) module has been installed. "My disk info' indicates that the drive works in mode ' Serial ATA/600", as I figured first it can be flown just SATA/300, and therefore it would make sense that the playback speed is capped at "."< 300="" mb/s.="" but="" this="" doesn't="" seem="" to="" be="" the="">

      Is that what I can do to improve performance?

      See you soon!

      NZ

      SOLUTION: Install the SSD drive in slot m2 next to one that contains the WIFI module. It will be free if you order the module WWAN / 3G. But it supports SATA III, while the slot under the battery is apparently not. In this regard, I am puzzled why Lenovo installed the module cache SATA original there.

    • Backups of Vista won't start does not as expected

      Backups of Vista were starting automatically as scheduled for the last 3 years, but now they do not start automatically.  The backup works fine when I start it manually.  I did not any changes to the schedule or to the device where the data is stored (external USB disk).  I recently put on maintenance of Vista via Windows Update, did not observe other problems.  Running Vista Home Premium 32-bit on a PC from Dell Quad with 4 GB of memory.  Any ideas on what is at the origin of the outbreak of backups to fail?

      Thank you
      zxk1

      Hello Zxk1,

      Thanks for posting in the Microsoft Answers forum! I suggest that search you your computer for any virus infection that may hinder your scheduled automatic backups. Below you will find a sew websites that provide public services that allows you to scan your computer from viruses and spyware:

      Microsoft Windows malicious removal tool
      This tool checks your computer infections by specific, prevalent malicious software (including Blaster, Sasser, and Mydoom) and helps to remove the infection if it is found. Microsoft will release an updated version of this tool the second Tuesday of each month.
      http://www.Microsoft.com/downloads/details.aspx?FamilyId=ad724ae0-e72d-4f54-9ab3-75b8eb148356&displaylang=en

      SuperAntiSpyware
      SUPERAntiSpyware Free Edition is 100% free and will detect and remove thousands of Spyware, Adware, Malware, Trojans, KeyLoggers, Dialers, Hi-Jackers, and worms.
      http://www.SUPERAntiSpyware.com/download.html

      Bytes of Malware Anti-malware (Freeware)
      http://www.download.com/Malwarebytes-anti-malware/3000-8022_4-10804572.html

       

      Trend Micro HouseCall - Free Online Virus and Spyware Scanner
      HouseCall is a free on-line virus scanner offered by Trend Micro, which checks if a computer has been infected by viruses, software spyware or other malicious software. HouseCall performs additional security checks to identify and fix vulnerabilities to prevent re-infection.
      http://housecall.trendmicro.com/

      Please let me know if this helps t solve your issueJ

      Adam
      Microsoft Answers Support Engineer
      Visit our Microsoft answers feedback Forum and let us know what you think

    • Backup of Windows 7 - change the settings - works does not as expected

      I'm trying to configure the backup of Windows 7 by using the "Change settings" option, but when I click on the link, all I get is a the Explorer window showing the contents of c:\Windows\System32

      Same thing if I click on the link 'manage space '.

      What I am doing wrong? or is it a mistake?

      Had the same prob, winlocker and shredder in the context menu, uninstalled winlocker and voila, backup now works.
      So, try to uninstall the software that hangs in the context menu (the menu "right click") and see if it works. Not interested in why at that time [is really starting to enjoy my Kubuntu box]

    • HTTP POST works does not as expected

      I can't understand why the POST with data works when I use Firefox, but not when sent from the BlackBerry. The only difference seems to be that the BlackBerry less sends the headers, but it's all legal HTTP.

      It's TCP data are sent to the server (from recorder package):

      ----------------------------------

      HTTP/1.1 POST/page
      Host: localhost
      Connection: close
      Content-Length: 8

      test = abc

      ----------------------------------

      That sounds about right. However, the Web Server table $_POST (PHP) is empty.

      Code follows:

           HttpConnection c = (HttpConnection)Connector.open(connectionString);
              c.setRequestMethod(HttpConnection.POST);
      
              DataOutputStream out = c.openDataOutputStream();
              URLEncodedPostData postData = new URLEncodedPostData(URLEncodedPostData.DEFAULT_CHARSET, true);
              postData.append("test", "abc");
      
              System.out.println("requestData: " + new String(postData.getBytes()));
              out.write(postData.getBytes());
              //out.flush();
      
              c.getResponseCode();
      
              InputStream is = c.openDataInputStream();
              LineReader lr = new LineReader(is);
      
              while(true)
              {
                  try
                  {
                      byte[] arr = lr.readLine();
                      System.out.println("Line: " + new String(arr));
                  }
                  catch(EOFException e) { break; }
              }
      

      Everyone knows about similar problems using POST?

      See you soon,.

      Pav

      Update:

      -J' tried this on 2 servers Web (Apache + PHP) unrelated, both have the same problem.

      SOLVED!

      I tried to put different headers that Firefox sends inside the request of BB and it does the job:

      c.setRequestProperty ("Content-Type", "application/x-www-formulaires-urlencoded");

      Hope it saves someone out there a lot of frustration :-)

    Maybe you are looking for