Trying to delete multiple files with very basic VBS script

Good day,
I've found a script and modified it for an input box to accommodate multiple files being deleted but I'm not sure if it is capable or if I'm just using the wrong syntax within the input box:
Script:
Set obj = CreateObject("Scripting.FileSystemObject") 'Calls the File System Object 
obj.DeleteFile inputbox("Enter files and path to be deleted") 'Deletes the file throught the DeleteFile function
When prompted and I put just one file path to the file I want deleted it works, but if I put in multiple files and their paths either separated by colan, semi colan or space, it says "bad file path or number".  If anyone knows of a VBS
or powershell script that references a text file or .csv spreadsheet that would be sooper handy!
Many thanks - RP
berto

Thank you Bill!
Sounds like I need a different method all together.  I found this script that references a .csv file with the folder paths and file names; does it seem legit to you guys?  Also for files that are past the 256 UNC character length, is there a work
around for that?
12
$files = Get-Content "C:\scripts\delete-files.csv"
13
14
foreach ($file in $files) {
15
    Remove-Item -Path
$file -force
16
17
18
write-host -foregroundcolor yellow "Delete action complete"
berto
Try this to see:
$files = Get-Content "C:\scripts\delete-files.csv"
foreach ($file in $files) {
Remove-Item -Path $file -force -WhatIf
write-host -foregroundcolor yellow "Delete action complete"
¯\_(ツ)_/¯

Similar Messages

  • Trying to delete a file with Powershell script ran by a service but issues with uac

    I'm having issues with a script that will delete a file on the C-Drive of a server. the script looks like this:
    param(
    [Parameter(Mandatory=$true)][string]$hostname
    $StrFileName = "C:\Program Files\NSClient++\nsclient.log"
    $LogLocal="c:\Nagios\naf_delete_nscp_log_file.log"
    $Date = Get-Date -Format "yyyy-MM-dd hh:mm:ss"
    "$date : NSClient logfile deletion requested on $hostname" | Out-File -filepath $LogLocal -Append
    If (Test-Path "$strFileName"){
    Remove-Item $strFileName -Force
    $Date = Get-Date -Format "yyyy-MM-dd hh:mm:ss"
    "$date : NSClient logfile deleted on $hostname" | Out-File -filepath $LogLocal -Append
    The script is initiated from a Nagios quick action which will use nrpe to pass the host as parameter and make the nscp service, which runs as local system, run it. It works perfectly on servers that have no uac enabled, but I can't get it to work on servers
    with uac. I've tried numerous options, but none seem to work. Any tips or advice to get this working with Powershell v2 code on servers with uac enabled is highly appreciated.
    Thanks.
    Willem

    Hi Willem,
    one thing to note: I don't see why your script itself has a hostname parameter.
    One way around UAC has always been the Windows Task Scheduler. If you register a task as System run and triggered by an event, you can simply call the event locally (which doesn't require admin permissions) and it will perform the task.
    I don't know how your Nagios construct works and the script by itself doesn't make much sense. If you want advice on how to do this without resorting to tasks, I'd need to know more about the system you are using.
    Cheers,
    Fred
    There's no place like 127.0.0.1

  • I'm trying to delete multiple pix in iPhoto that i stupidly made duplicates of without knowing, I've tried going into the applications folder and using image capture but i think I've missed a step , can anyone send the correct info / steps pls thanks

    I'm trying to delete multiple pix in iPhoto that i stupidly made duplicates of without knowing, I've tried going into the applications folder and using image capture but i think I've missed a step , can anyone send the correct info / steps pls thanks

    again image capture is not involved with deleting photos from iPhoto in any way ever
    the paid version of iPhoto Library Manager is very good for finding duplicates as is Duplicate Annihilator
    And I have no idea who told you this - or what it means - but re-read both of my opening statements
    I was told I could delete multpiles thru image capture by transferring my iPhoto library etc
    LN

  • Retaining links when deleting multiple files

    Hi there,
    I need to delete a lot of files from a project, but I don't
    want to lose the links to those topics in other files. If I delete
    a single file, Robohelp HTML displays a dialog box that gives the
    option to keep references to that file in other files. This is the
    behaviour I want to achieve.
    When I try to delete multiple files, however, Robohelp
    doesn't give the option to keep the references and the links
    disappear from other files.
    Does anyone know any way to delete mulitple files and keep
    all references to those files? I really don't want to have to
    delete every topic individually!
    Many thanks
    Kate

    Hi Rick,
    Thanks very much for that quick reply. That's a good idea - I
    don't why I didn't think of it
    I deleted some files and they disappeared from Robohelp
    before my very eyes...then I tried again in another folder and they
    didn't disappear, but nasty red crosses appeared on their icons. It
    doesn't seem to matter whether I have Robohelp open or closed - the
    red crosses appear all the time now.
    Any ideas why some topics delete seamlessly, and Robohelp
    doesn't want to let go of others?
    Cheers
    Kate

  • Multiple files with same name--- automatic renaming option??

    I am trying to sort my files by adding multiple files to a single folder. However, many have the same filename, and I get the error " there already exists a file with the name "x", please choose another name" etc. I am dealing with thousands of files here that are very tedious to rename individually. Is there an option or program that either disables this block on multiple files with the same name in a common folder, or automatically renames the files as they are placed in the folder?

    i would like all the files to have different names, but not have to do it myself. they are generated my my audio recorder, which automatically names files take1, take2, take3 etc. multiple sessions entail multiple folders, i am trying to consolidate.

  • Upload multiple files WITH correct pairs of form fields into Database

    In my form page, I would like to allow 3 files upload and 3 corresponding text fields, so that the filename and text description can be saved in database table in correct pair. Like this:
    INSERT INTO table1 (filename,desc) VALUES('photo1.jpg','happy day');
    INSERT INTO table1 (filename,desc) VALUES('photo2.jpg','fire camp');
    INSERT INTO table1 (filename,desc) VALUES('photo3.jpg','christmas night');
    However, using the commons fileupload, http://commons.apache.org/fileupload/, I don't know how to reconstruct my codes so that I can acheieve this result.
    if(item.isFormField()){
    }else{
    }I seems to be restricted from this structure.
    The jsp form page
    <input type="text" name="description1" value="" />
    <input type="file" name="sourcefile" value="" />
    <input type="text" name="description2" value="" />
    <input type="file" name="sourcefile" value="" />The Servlet file
    package Upload;
    import sql.*;
    import user.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.util.Map;
    import java.util.HashMap;
    import java.util.Date;
    import java.util.List;
    import java.util.Iterator;
    import java.io.File;
    import java.io.PrintWriter;
    import java.io.IOException;
    import java.text.SimpleDateFormat;
    import org.apache.commons.fileupload.servlet.ServletFileUpload;
    import org.apache.commons.fileupload.disk.DiskFileItemFactory;
    import org.apache.commons.fileupload.*;
    public class UploadFile extends HttpServlet {
    private String fs;
    private String category = null;
    private String realpath = null;
    public String imagepath = null;
    public PrintWriter out;
    private Map<String, String> formfield = new HashMap<String, String>();
      //Initialize global variables
      public void init(ServletConfig config, ServletContext context) throws ServletException {
        super.init(config);
      //Process the HTTP Post request
      public void doPost(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("utf-8");
        response.setCharacterEncoding("utf-8");
        response.setContentType("text/html");
        PrintWriter out = response.getWriter();
        Thumbnail thumb = new Thumbnail();
        fs = System.getProperty("file.separator");
        this.SetImagePath();
         boolean isMultipart = ServletFileUpload.isMultipartContent(request);
         if(!isMultipart){
          out.print("not multiple part.");
         }else{
             FileItemFactory factory = new DiskFileItemFactory();
             ServletFileUpload upload = new ServletFileUpload(factory);
             List items = null;
             try{
                items = upload.parseRequest(request);
             } catch (FileUploadException e) {
                e.printStackTrace();
             Iterator itr = items.iterator();
             while (itr.hasNext()) {
               FileItem item = (FileItem) itr.next();
               if(item.isFormField()){
                  String formvalue = new String(item.getString().getBytes("ISO-8859-1"), "utf-8");
                  formfield.put(item.getFieldName(),formvalue);
                  out.println("Normal Form Field, ParaName:" + item.getFieldName() + ", ParaValue: " + formvalue + "<br/>");
               }else{
                 String itemName = item.getName();
                 String filename = GetTodayDate() + "-" + itemName;
                 try{
                   new File(this.imagepath + formfield.get("category")).mkdirs();
                   new File(this.imagepath + formfield.get("category")+fs+"thumbnails").mkdirs();
                   //Save the file to the destination path
                   File savedFile = new File(this.imagepath + formfield.get("category") + fs + filename);
                   item.write(savedFile);
                   thumb.Process(this.imagepath + formfield.get("category") +fs+ filename,this.imagepath + formfield.get("category") +fs+ "thumbnails" +fs+ filename, 25, 100);
                   DBConnection db = new DBConnection();
                   String sql = "SELECT id from category where name = '"+formfield.get("category")+"'";
                   db.SelectQuery(sql);
                    while(db.rs.next()){
                      int cat_id = db.rs.getInt("id");
                      sql = "INSERT INTO file (cat_id,filename,description) VALUES ("+cat_id+",'"+filename+"','"+formfield.get("description")+"')";
                      out.println(sql);
                      db.RunQuery(sql);
                 } catch (Exception e){
                    e.printStackTrace();
            HttpSession session = request.getSession();
            UserData k = (UserData)session.getAttribute("userdata");
            k.setMessage("File Upload successfully");
            response.sendRedirect("./Upload.jsp");
      //Get today date, it is a test, actually the current date can be retrieved from SQL
      public String GetTodayDate(){
        SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd");
        String today = format.format(new Date());
        return today;
      //Set the current RealPath which the file calls for this file
      public void SetRealPath(){
        this.realpath = getServletConfig().getServletContext().getRealPath("/");
      public void SetImagePath(){
        this.SetRealPath();
        this.imagepath = this.realpath + "images" +fs;
    }Can anyone give me some code suggestion? Thx.

    When one hits the submit button - I then get a 404 page error.What is the apaches(?) error log saying? Mostly you get very useful information when looking into the error log!
    In any case you may look at how you are Uploading Multiple Files with mod_plsql.

  • How can I delete multiple files at a time from "Finder"

    I can't possible delete the thousands of junk files that showed up in Finder once I downloaded Maverick.  I can't delete more than one at a time now.  Why won't the highlighting stay in place on more than one file that I want to delete?

    How are you trying to select multiple files?
    What makes you think that "thousands of junk files [...] showed up in Finder once I downloaded Maverick" (or even installed it)?

  • Deleting multiple files in aperture

    How do I delete multiple files? I think it involves the apple key + another key but I cannot find a reference to it.
    Also, where is the setting for changing "primary only"?
    Thanks in advance!

    You can't select multiple items in the Project Inspector.
    To delete multiple images use the shift key to select contiguous images or the Command key to select non-contiguous images. Then press command + delete.
    Primary only is under the edit menu and there's a button with a "1" on it
    DLS.

  • I've can't open any applications on my Mac ! I tried to delete some files from safari (history) and then none of the apps including iphoto, safari, mail, facetime. I don't know how to fix it, help ? any idea ?

    I've can't open any applications on my Mac ! I tried to delete some files from safari (history) and then none of the apps including iphoto, safari, mail, facetime. I don't know how to fix it, help ? any idea ?

    Please read this whole message before doing anything.
    This procedure is a diagnostic test. It’s unlikely to solve your problem. Don’t be disappointed when you find that nothing has changed after you complete it.
    The purpose of the test is to determine whether the problem is caused by third-party software that loads automatically at startup or login, or by a peripheral device. 
    Disconnect all wired peripherals except those needed for the test, and remove all aftermarket expansion cards. Boot in safe mode and log in to the account with the problem. Note: If FileVault is enabled, or if a firmware password is set, or if the boot volume is a software RAID, you can’t do this. Ask for further instructions.
    Safe mode is much slower to boot and run than normal, and some things won’t work at all, including sound output andWi-Fi on certain iMacs. The next normal boot may also be somewhat slow.
    The login screen appears even if you usually log in automatically. You must know your login password in order to log in. If you’ve forgotten the password, you will need to reset it before you begin. Test while in safe mode. Same problem? After testing, reboot as usual (i.e., not in safe mode) and verify that you still have the problem. Post the results of the test.

  • Every time I am trying to open Quicktime files with my Quicktime it wants to convert the files. Why?

    Every time I am trying to open Quicktime files with my Quicktime it wants to convert the files. Why?

    QuickTime version 10.3 will "convert" older legacy codecs into a more modern version. You can save this newer version and delete the older one.
    This can only mean that support for those codecs will be removed completely some time in the future.

  • Getting error while trying to delete multiple rows

    Hi Experts,
    Working in jdev 11.1.1.3.0 with ADF BC and rich faces.
    i am trying to delete multiple records from the table, everything is working fine if i use filter or not using horizontal scroll bar of the table. if i try to delete last records on the table and the records are deleting from UI and from the DB also, but i am getting error like
    ADFv:Count not find row:_$<to-calc>$_with key:oracle.jbo.key[2333] inside parent: XxwfsAvcardXXXXXXXVO1Iterator with key:null
    I have changed my method with the below link
    Re: JDev 11g-Multiple Row Selection Table-Ctrl+A error
    but till i am getting the same error:
    Method:
    public void deleteRec(ActionEvent actionEvent) {
    // Add event code here...
    RowKeySet rowKeySet = (RowKeySet)this.embossTB.getSelectedRowKeys();
    CollectionModel cm = (CollectionModel)this.embossTB.getValue();
    Row specRow = null;
    ArrayList rowList = new ArrayList();
    int listLength = 0;
    ArrayList<Number> printReqLST=new ArrayList<Number>();
    ViewObject vo1=null;
    boolean flag=false;
    for (Object facesTreeRowKey : rowKeySet) {
    cm.setRowKey(facesTreeRowKey);
    JUCtrlHierNodeBinding rowData = (JUCtrlHierNodeBinding)cm.getRowData();
    specRow = rowData.getRow();
    rowList.add(specRow);
    listLength++;
    for (int index = 0; index < listLength; index++){
    specRow = (Row)rowList.get(index);
    Number printReqID = (Number)specRow.getAttribute("PrintRequestId");
    String PrintState = specRow.getAttribute("PrintState").toString();
    if (PrintState.equalsIgnoreCase("PRINTED")) {
    System.out.println("cann't delete");
    FacesContext fctx = FacesContext.getCurrentInstance();
    FacesMessage message =
    new FacesMessage("Cann't Delete the selected row:" + printReqID);
    message.setSeverity(FacesMessage.SEVERITY_ERROR);
    fctx.addMessage(null, message);
    } else {
    System.out.println("delete");
    flag=true;
    specRow.remove();
    if(flag){
    System.out.println("before commit");
    commitRows();
    Can any one help me....

    Can any one help me...
    i written logic in AM but still i am facing the same issue.
    can any one help me, is this is bug or coding issue.
    If i am not doing scroll down and trying to delete rows then there is no error.... only error is coming when i scroll down and try to delete.
    Method:
    public void deleteRec(ActionEvent actionEvent) {
    // Add event code here...
    RowKeySet rowKeySet = (RowKeySet)this.embossTB.getSelectedRowKeys();
    CollectionModel cm = (CollectionModel)this.embossTB.getValue();
    List<Row> rowsToDelete = new ArrayList<Row>();
    for (Object facesTreeRowKey : rowKeySet) {
    cm.setRowKey(facesTreeRowKey);
    JUCtrlHierNodeBinding rowData = (JUCtrlHierNodeBinding)cm.getRowData();
    Number printReqID = (Number)rowData.getAttribute("PrintRequestId");
    String PrintState=rowData.getAttribute("PrintState").toString();
    if (PrintState.equalsIgnoreCase("PRINTED")){
    System.out.println("cann't delete");
    FacesContext fctx = FacesContext.getCurrentInstance();
    FacesMessage message =
    new FacesMessage("Cann't Delete the selected row:" + printReqID);
    message.setSeverity(FacesMessage.SEVERITY_ERROR);
    fctx.addMessage(null, message);
    } else{
    System.out.println("delete");
    Row row1 = rowData.getRow();
    rowsToDelete.add(row1);
    // deletePrintRecords(printReqID);
    for (Row row : rowsToDelete){
    System.out.println("inside deleting rows");
    row.remove();
    //commitRows();
    System.out.println("After commit from am");
    public void commitRows(){
    // System.out.println("commit");
    DCIteratorBinding embossIter =
    ADFUtils.findIterator("XxwfsAvcardEmbossInterfaceVO1Iterator");
    ADFUtils.invokeEL("#{bindings.Commit.execute}");
    embossIter.getViewObject().executeQuery();
    AdfFacesContext.getCurrentInstance().addPartialTarget(embossTB);
    Edited by: user5802014 on Sep 3, 2010 11:47 AM
    Edited by: user5802014 on Sep 3, 2010 1:07 PM

  • Problem when trying to delete rejected files in LR 5.2.

    When I try to delete rejected files I enter the library module, select all photographs by their rejected flag status and using the cmd and backspace keys, I get the usual message offering me the options of canceling, deleting from the disk or remove from catalogue.  Choosing delete from disc I then get a pop up window that says there were (x amount) of files that could not be moved to the trash folder.  It does this whether I try to delete all images flagged as rejected at the same time or go file by file and delete them in ones and twos.  I am using a mac.  The trash folder is empty.

    Got it sorted so I thought I would share the solution here:  The problem wasnt related to LR 5.2 but was to do with Mac OS X 10.8.5 AKA Mountain Lion.  I had also noticed that I was having an issue around deleting anything on my MAC.  When I tried to delete a file from anywhere I was asked to submit my password.  The message I got was finder wants to make a change please submit password.  I checked through the mountain Lion forums and found a solution here; https://discussions.apple.com/message/20499360#20499360%2320499360
    I implemented it and the problem has dissappeared.

  • Trying to delete some files from a flash template (.fla file) in flash

    Hi I am trying to delete some files from a flash template I purchased,  when I open the .fla file in flash and go into the library, I would like  to delete the contact box and the mp3 player, when I locate those files  in the library and delete the files, the website no longer opens up (it  will not work when I delete those files from the library) what am I  doing wrong ? please help, I am fairly new to flash.

    Ned - Nice to have guys like your good self giving the advice you do!
    Hope the chap sorts out his mp3 library Problems!
    For my part, I don't want to even try come to terms with FLASH - great as it is.
    If you would like to have the job of making changes for me @  Footballtipping.co.uk/ - let me know. Contact - [email protected]
    You will be rewarded to your liking! -
    Regards all & keep at it!
    Mike Roche

  • How to check-in multiple files with same name having different revision num

    Hi
    Can anyone please tell me, how to check-in multiple files with the same name with different revision number using RIDC API.
    For eg:
    First I will check-in a file(TestFile.txt) into a content server with revision number 1 using RIDC API in ADF application. Then after some time, will modify the same file(TestFile.txt) and check-in again. I tried to check-in same file multiple times, however first time its checking-in correctly into server showing revision as 1, while checking-in same file again, its not giving any errror message, and also its not reflecting in server. Only one file(TestFile.txt) is reflecting in server.
    How to implement this functinality using RIDC API? Any suggestions would be helpful.
    Regards
    Raj
    Edited by: 887680 on Mar 6, 2013 10:48 AM

    Hi Srinath
    Thanks for your response. Its not cloning, its like check-in file first, then check-out the file and do some editing and then again upload the same file with different revision number using RIDC. I got the solution now.
    Regards
    Raj

  • How to delete the file with space in name

    Hi
    I want to delete the file "test ex.txt" file.
    i run the following command in command prompt.i can delete the file successfully.
    /bin/rm -f /mnt/"test ex.txt"
    I want to run the command from java.So i am using the following code
    String cmd = "/bin/rm -f /mnt/\"test ex.txt\"";
         Runtime rt = Runtime.getRuntime();
    process = rt.exec(cmd);
    The file was not deleted.
    How to delete the file with space in name?
    Help me

    Use the form of exec that takes an array of command + args.
    arr[0] = "/bin/rm"
    arr[1] = "-f"
    arr[2] = "/home/me/some directory with spaces";Or use ProcessBuilder, which is the preferred replacement for Runtime.exec, and which Runtime.exec calls.

Maybe you are looking for

  • Is there a NAS box that works well with OSX

    I've always struggled with NAS boxes & OSX.  Sure, I can connect them up, and copy files to and from a mac, but eventually I always seem to run into issues.  Suddenly I can no longer access the files, or I can no longer connect at all, or it fails to

  • UWL Filter causing error while approving Leave Request

    Hi Guys, We recently applied MSS SP17 and we changed our UWL filter BADI to SWK1 Function group - SWK_LOCAL_INBOX_GET. The filter works fine, but when we try to approve leave request, it somehow calls this piece of code again and does not allow (DUMP

  • Changes to Purchase order also changes sales order prices

    We have a unique problem which cannot be replicated and occurs once in a while. Sometimes when a purchase order which has the account assignment as sales order is changed, the corresponding sales order line item suddenly loses its net value and becom

  • Why does my Gopro black 3+ video look so bad on PRE11 while editing & after DVD creation playback.

    Well let start with.  When I do a project with video from my Samsung S4 phone or my IPhone 5 or my Canon T4i  looks great on computer screen and when I play back a burned DVD or AVHCD.  I just directly import from file on my hard drive.  My Samsung i

  • Managed APs using WPA2?

    I am confused about using ESM with corporate APs running WPA or WPA2 encryption. In the Wi-Fi Security tab of the policy I am working on I can set WPA as a minimum encryption strength, but I can't figure out how to then add managed APs with a 64 hexa