Deleting Files and (sub)folders - how to

Hi,
Easy question. Easy there a vbscript to delete all files and (sub)folders, empty or not. Important, here is that the parent folder must NOT be deleted, only it´s contents. (important: this folder is located on a mapped share \\servername\foldername\)
please help

Hi,
' Delete All Subfolders and Files in a Folder
Const DeleteReadOnly = TRUE
Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.DeleteFile("C:\FSO\*"), DeleteReadOnly
objFSO.DeleteFolder("C:\FSO\*"),DeleteReadOnly
Save the above code in test file with .vbs file extension. modify "C:\FSO" to your folder.
Disclaimer: This posting is provided AS-IS with no warranties or guarantees and confers no rights. Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually
answer your question. This can be beneficial to other community members reading the thread.

Similar Messages

  • Jsp code (js code) to display(tree) the files and sub folders in a folder

    Hi all
    plz can any one send me the source in jsp or js to display in tree structure for files and sub folders in a folder.

    There are dozens of Javascript tree widgets available on the Internet. Some are free. Some are good. Google will find them for you.
    (The only relevance of JSP to your question is that yes, you can generate HTML that uses one of those Javascript tree widgets.)

  • Urgent ! How to Zip Folder Contents including files and sub folders.

    Hi, i need an urgent help from you regarding zipping the contents of any folder/directory including its sub folders and files to a .zip file. Please provide a code for ot or help me out. It is really very urgent.
    Thanx Waiting....

    This class can add a string or file to a ZIP. Maybe you can adapt it to do a directory and all its subfolders and files recursively:
    package demo;
    import java.io.BufferedReader;
    import java.io.ByteArrayInputStream;
    import java.io.ByteArrayOutputStream;
    import java.io.File;
    import java.io.FileReader;
    import java.io.IOException;
    import java.util.zip.GZIPInputStream;
    import java.util.zip.GZIPOutputStream;
    import java.util.zip.ZipException;
    * Demo for using the Zip facilities to compress data
    public class ZipDemo
        /** Default buffer size */
        private static final int DEFAULT_BUFFER_SIZE = 4096;
         * Compress a string
         * @param uncompressed string
         * @return byte array containing compressed data
         * @throws IOException if the deflation fails
        public static final byte [] compress(final String uncompressed) throws IOException
            ByteArrayOutputStream baos  = new ByteArrayOutputStream();
            GZIPOutputStream zos        = new GZIPOutputStream(baos);
            byte [] uncompressedBytes   = uncompressed.getBytes();
            zos.write(uncompressedBytes, 0, uncompressedBytes.length);
            zos.close();
            return baos.toByteArray();
         * Uncompress a previously compressed string;
         * this method is the inverse of the compress method.
         * @param byte array containing compressed data
         * @return uncompressed string
         * @throws IOException if the inflation fails
        public static final String uncompress(final byte [] compressed) throws IOException
            String uncompressed = "";
            try
                ByteArrayInputStream bais   = new ByteArrayInputStream(compressed);
                GZIPInputStream zis         = new GZIPInputStream(bais);
                ByteArrayOutputStream baos  = new ByteArrayOutputStream();
                int numBytesRead            = 0;
                byte [] tempBytes           = new byte[DEFAULT_BUFFER_SIZE];
                while ((numBytesRead = zis.read(tempBytes, 0, tempBytes.length)) != -1)
                    baos.write(tempBytes, 0, numBytesRead);
                uncompressed = new String(baos.toByteArray());
            catch (ZipException e)
                e.printStackTrace(System.err);
            return uncompressed;
         * Uncompress a previously compressed string;
         * this method is the inverse of the compress method.
         * Implemented in terms of the byte array version.
         * @param string containing compressed data
         * @return uncompressed string
         * @throws IOException if the inflation fails
        public static final String uncompress(final String compressed) throws IOException
            return ZipDemo.uncompress(compressed.getBytes());
         * Main driver class for ZipDemo
         * @param command line arguments - either string or file name to compress
        public static void main(String [] args)
            try
                for (int i = 0; i < args.length; ++i)
                    String uncompressed = "";
                    File f              = new File(args);
    if (f.exists())
    BufferedReader br = new BufferedReader(new FileReader(f));
    String line = "";
    StringBuffer buffer = new StringBuffer();
    while ((line = br.readLine()) != null)
    buffer.append(line);
    br.close();
    uncompressed = buffer.toString();
    else
    uncompressed = args[i];
    System.out.println("length before compression: " + uncompressed.length());
    byte [] compressed = ZipDemo.compress(uncompressed);
    System.out.println("length after compression : " + compressed.length);
    String compressedAsString = new String(compressed);
    System.out.println("length of compressed str : " + compressedAsString.length());
    byte [] bytesFromCompressedAsString = compressedAsString.getBytes();
    boolean isTheSameAs = bytesFromCompressedAsString.equals(compressed);
    System.out.println("compressed bytes are " + (isTheSameAs ? "" : "not ") + "the same as from String");
    System.out.println("length of bytesFrom...: " + bytesFromCompressedAsString.length);
    String restored = ZipDemo.uncompress(compressed);
    System.out.println("length after decompress : " + restored.length());
    isTheSameAs = restored.equals(uncompressed);
    System.out.println("original is " + (isTheSameAs ? "" : "not ") + "the same as the restored");
    String restoredFromString = ZipDemo.uncompress(compressedAsString);
    isTheSameAs = restoredFromString.equals(uncompressed);
    System.out.println("original is " + (isTheSameAs ? "" : "not ") + "the same as the restored from string");
    catch (Exception e)
    e.printStackTrace(System.err);
    MOD

  • Delete files and sub-directories over created over 1 year ago

    Hi Josh,
    Have a look at this script I got for cleaning up a scans folder.
    It's a bit over the top but it works.

    Hello,
    I have a batch script that runs at the start of every month which clears report files and moves them into an archive directory in a folder with the date of the move. So the archive folder doesn't fill up i want to run a script on it that clears out any folders created over 1 year ago.
    I've got:
    Set dir="C:\aa_Mine\test\testto"
    Echo Deleting all files from %dir%
    del %dir%\* /F /Q
    Echo Deleting all folders from %dir%
    for /d %%p in (%dir%\*) Do rd /Q /S %%p
    pause
    which deletes all the files and folders in the directory but is there a way only doing it for ones edited over 1 year ago. I tried to add the /minage: command but its not supported.
    Any ideas?
    Cheers
    This topic first appeared in the Spiceworks Community

  • How To Add Folders and Sub Folders

    I am brand new (1 week) to my new Mac (iMac). In my Windows-based PC I used to have, for example, a folder named PHOTOS followed by sub folders designating certain categories that work for me, such as, "Family", "Vacations" etc, and I would make sure that all my uploads from my camers went to the appropriate folder.
    I would like to accomplish the same thing in my Mac, but have no idea how to go about it. I do not even know how to create such folders and sub folders.
    Is someone out there who can help, please?

    pstoll
    In the Finder: File -> New Folder creates a new Folder. To nest a folder inside another one then simply drag the second one to the first.
    But if you're trying to organise your photos, there's a much better way to do that on your Mac. Check out iPhoto It's a photo manager that's integrated throughout the Operating System. It's much, much more flexible than a bunch of folders in the Finder. You can keyword your pics, populate Smart Albums automatically, rate and edit your pics, all via iPhoto.
    You can find out more here:
    http://www.apple.com/ilife/iphoto/
    there are some tutorials here
    http://www.apple.com/ilife/tutorials/#iphoto
    and a good forum here:
    http://discussions.apple.com/category.jspa?categoryID=143
    My best advice is to explore the app by dragging in maybe 100 pics and testing things out, gettting the hang of it. It's miles better than a folder hierarchy.
    Regards
    TD

  • How to create folders and sub folders in numbers on my mac book pro?, how to create folders and sub folders in numbers on my mac book pro?

    I am new to Mac and numbers how do I create folders and sub folders on my mac book pro ? I have created folders on my ipad3 but I cant seem to make a sub folder ?
    Can any one help ?
    Thanks in advance!

    To create a folder either select New Folder from the Finder's File menu or the keyboard equivalend command-shift-N.  Select that folder and do the same. Viola!  You have a folder inside a folder.

  • Little help please regarding deleting files and folders...

    My wife has a MBP and has accumulated some old items in her documents folder that she'd like to delete. She has a USB mouse but the "right click" doesn't appear to work. She's running 10.4.11 and can't reveal the files in icon mode to facilitate dragging to trash. Certainly there is a sequence of keystroke commands that will allow these files to be effectively trashed, but our "control/delete", or "apple/delete", or "option/delete" doesn't do the trick after highlighting the subject file. Help please! TIA!

    To delete a file or folder, high light it then using the keyboard type Command Delete and that will delete it. If you have multiple files and/or folders the same keyboard commands apply.
    Regards,
    Roger

  • I have recently changed to an iMac from a Windows PC. How do I delete files and format the memory card in my helmet cam?

    I have recently changed to an iMac from a Windows PC. How do I delete files and reformat the memory card in my helmetcam?

    If you return the memory card to the helmetcam, it may choose to reformat it before use; back to some FAT-16 or FAT-32 format many of these third-party cards and cameras use. Unless you were going to use it for Mac OS X and format it with HFS+ or in a partition map for Mac data, etc.
    If not, the easiest way to reformat the card may have been in the camera itself. I've formatted several kinds of camera cards, drives, USB flash drive, and others. The means varies with the intended purpose. Sometimes the default is the best; since it is platform neutral if the device is seen by both players.
    Good luck & happy computing!

  • HT201250 When restoring Time Machine after a failure, does it also restore the files to the same order, for example - within iPhoto I have pics/ videos in folders and sub folders organised as family/events etc - will it go back to this exact order after a

    When restoring Time Machine after a failure, does it also restore the files to the same order, for example - within iPhoto I have pics/ videos in folders and sub folders organised as family/events etc - will it go back to this exact order after a restore?

    Hi Stavros0203,
    When restoring your entire system from a Time Machine backup, it is restored to the state it was when that backup was made. See this article for reference -
    OS X Yosemite: Recover your entire system
    Thanks for using Apple Support Communities.
    Best,
    Brett L

  • My Macbook Air can delete files and folders and take them to Trash Can but cannot delete from Trash Can . Cannot empty trash securely.

    My Macbook Air can delete files and folders and take them to Trash Can but cannot delete from Trash Can . Cannot empty trash securely.

    Launch the Console application in any of the following ways:
    ☞ Enter the first few letters of its name into a Spotlight search. Select it in the results (it should be at the top.)
    ☞ In the Finder, select Go ▹ Utilities from the menu bar, or press the key combination shift-command-U. The application is in the folder that opens.
    ☞ Open LaunchPad. Click Utilities, then Console in the icon grid.
    Make sure the title of the Console window is All Messages. If it isn't, select All Messages from the SYSTEM LOG QUERIES menu on the left. If you don't see that menu, select
    View ▹ Show Log List
    from the menu bar.
    Click the Clear Display icon in the toolbar. Then try the action that you're having trouble with again. Select any messages that appear in the Console window. Copy them to the Clipboard by pressing the key combination command-C. Paste into a reply to this message by pressing command-V.
    When posting a log extract, be selective. In most cases, a few dozen lines are more than enough.
    Please do not indiscriminately dump thousands of lines from the log into this discussion.
    Important: Some private information, such as your name, may appear in the log. Anonymize before posting.

  • My Mac Book Pro is giving me a message that the start up disk is full, how do I delete files, and what files should I be deleting

    My Mac Book Pro is giving me a message that the start up disk is full, how do I delete files, and what files should I be deleting

    There are several nice programs that can help you figure out what's on your computer - OmniDiskSweep, WhatSize, and DaisyDisk are the three I like. If you've had your computer for a while - and especially if this isn't your first Mac and you've been migrating from one computer to another, one of these programs can help you find files you didn't know your computer still had. For example, when I was trying to shed files to fit int a 256GB SSD, I discovered I had nearly 1GB of files in my Application Support folder belonging to programs I no longer used.
    Other than that, your easy choice are music, video, and photos. They tend to be the big files. A movie will generally be at least 1.25GB, for example.

  • Bridge - can't delete files in some folders

    I just installed CS3 on my new PC. My problem is that in SOME (but not all) folders when I hit delete to get rid of some files it just totally ignores the command - it's not rejecting it - i've tried ALT+ delete and even the dustin icon at the top right hand side. NOTHING - it's as if i haven't pressed anything.
    then i've opened other folders (on the same drive) and the delete works like a dream. around half the folders on my drive have 'deletable' files and half are completely stuck. I copied one folder onto a different drive and from there i am able to deletes files from it.
    any ideas what is going on????????????????
    thanks
    desperate in London!

    Thanks curt young, that was the ticket.
    I'm running Vista 64 with 8GB of memory, quad core, because it's noticeably faster than XP. I too am always in Administrator mode.
    But...I had the "permissions" message too, right clicking on the icon, going into Properties, then clicking on Compatibility tab, then checking the "Run this program as an administrator" box solved the problem instantly on next program load.
    Vista...what a concept. For that matter, Bridge, what a concept. As in, great concept, when are you guys at Adobe going to fix all the bugs in this useful but klugey program?
    But at least it's working for now after the fix, thanks again curt.
    How stupid is it for a program or an OS to require that, even though you're logged in as Admin, you have to tell the program to run in Admin? Just lame as all heck. ;-) Don't mind me, I'm in a rant mood this morning.
    peace, love, Obama 08

  • Working with Folders and Sub-Folders

    I'm updating this big site, and its pages are organized into
    folders. I've only ever organized my images and .pdf files with
    folders not my html files but all my prior sites have never had so
    many files as this one. It’s starting to drive me crazy
    though because pages in folders aren't connecting to scripts in the
    scripts folder, menus aren't working right because of it and I'm
    not sure what I can do to fix it.
    My question is if images are showing up in these sub-pages,
    the linked css is being applied in these sub-pages why are the
    scripts not working in the sub-pages? For example, all the top
    level pages easily connect to the rotating JavaScript banner, but
    as soon as you go into a sub-folder page the banner disappears. All
    these files are being updated via templates so any changes I'm
    doing is affecting all the pages the same. That’s why
    it’s confusing me why an image would connect the same but a
    script wouldn't. Don't they search for their links root down or
    does it search the folder its in down? How can you get templates to
    work under such conditions where files are both in the root and in
    folders and sub-folders?
    Site reference is:
    http://golfforkids.net/focus/index.html
    Please note that this is a temporary domain for testing. The
    top menu will pop up a window saying that it needs to be
    registered. They are, just not to that domain and I don't have
    access to the native domain. Sorry for the inconvenience!
    Thank you for any clarification!!!

    ''"Are you subscribed to those subfolders?
    File (Alt-F) - Subscribe"''
    Please see #2 in original post:
    ''"2) Trying to Subscribe to folders only shows Inbox, not sub-folders for Inbox."''
    Attached is an image illustrating this (this screenshot was taken after forcing Thunderbird to show Inbox folders as described in #3 of OP)
    {In OP I was unable to attach images}

  • I am struggling! Help! I need to move 3500 pics-in TIFF format in 175 folders and sub folders from my old PSE6, Windows XP to my new PSE13, Windows8.1. I have the PSE6 backed up on an external hard drive. What is the safe way to do this? Can anyone at Ado

    I am struggling! Help! I need to move 3500 pics-in TIFF format in 175 folders and sub folders from my old PSE6, Windows XP to my new PSE13, Windows8.1. I have the PSE6 backed up on an external hard drive. What is the safe way to do this? Can anyone at Adobe help me? Please?

    Use the Organizer backup & restore method, starting the restore from the TLY file. Probably best to use a custom location as the XP file structure will be different. See this link for further help:
    http://helpx.adobe.com/photoshop-elements/kb/backup-restore-move-catalog-photoshop.html

  • Can I transfer files to sub folders in itune apps.i It seems I can't.

    I have the app office2hd and I'm trying to transfer files and folders to the app from my win 7 pc within iTunes.
    I can transfer files okay but when I try yo double click a folder to get it to open the sub folder under it, but it does not open.
    I have had to open the folders and sub folders on my pc and transfer the files to the root of office2hd and then have to recreate the folders on the iPad in office2hd then move the files from he root to the folder they belong in. A very long process. With over 300 files.
    Can anyone offer me a better suggestion please?
    Thanks
    Oz

    Hi Stan, and a warm welcome to the forums!
    Depends on several things...
    If the Disk Format is MS/DOS, then yes.
    If it is HFS+/Mac Os Extended, then only if you have MacDrive on your PC...
    http://www.mediafour.com/products/macdrive/
    Unfortunately DU can't fix all that much, your best bet is DiskWarrior.
    http://www.alsoft.com/DiskWarrior/
    If DW can't fix it, you might try Data Rescue II...
    http://www.prosofteng.com/products/data_rescue.php
    (Has a Free Demo to see if it could or not, but you'll need another drive to recover to).
    Or FileSalvage...
    http://www.subrosasoft.com/OSXSoftware/index.php?%20mainpage=product_info&productsid=1

Maybe you are looking for

  • The administration console doesn't refresh

    Hello, I used WebCenter Portal Administration Console (http://<server>:<port>/<context_root>/admin to delete a page at runtime. Then I added new pages in the page hierarchy in my portal application, which I would like to see in the admin console too,

  • ITunes 11.1.1 Update Error - Mac OS X 10.6.8 Snow Leopard

    Hello iTunes Community! I've been reading about the non-descript error message that Windows users are getting when attempting to update to iTunes 11.1.1.  It appears to affect Mac OS X as well in that I too am getting the same error.  I'm running a 2

  • Western Digital drives lose directory in Mavericks

    I was just informed by Western Digital that there is an incompatibility between their drives and Mavericks!   I connected my MY Book Thunderbolt Duo and found that both drives showed up on my Desktop without any data.   WD advised of the Mavericks di

  • I get an error message when I try to burn to disc

    I get an error message when I try to burn Playlists.  It says no burning software found.  I have deleted ITunes and reinstalled it but I still get that message.

  • Buttons don't return from down state

    Hello, When I use component buttons, the green border never goes away. If there are thre buttons on the screen, they all appear to have focus. I am using MX 2004 and I have only noticed this problem since upgrading the flash player to version 9. Is a