balubeto Posted June 12, 2009 Posted June 12, 2009 HII would need a script that it deletes all the subdirectories (with their contents) except those mentioned by me. These subdirectories and their files may have any attribute. This script must run on Windows PE 2.1 32/64 bit and on Windows Vista SP1 32/64 bit.THANKSBYE
balubeto Posted June 12, 2009 Author Posted June 12, 2009 The problem is what I not am capable of programming. So, I'm looking for someone willing to do this simple script.THANKSBYE
Tripredacus Posted June 12, 2009 Posted June 12, 2009 http://www.microsoft.com/resources/documen...r.mspx?mfr=trueexample: rmdir c:\temp\*.* /s /qYou'll have to play with it, as the above example deletes the files but leaves the folders. I use this in one of my scripts but never bothered fixing it.
balubeto Posted June 12, 2009 Author Posted June 12, 2009 (edited) http://www.microsoft.com/resources/documen...r.mspx?mfr=trueexample: rmdir c:\temp\*.* /s /qYou'll have to play with it, as the above example deletes the files but leaves the folders. I use this in one of my scripts but never bothered fixing it.Perhaps you have not understood well:I want a script that works with Windows PE 2.1 32/64 bit and with Vista SP1 32/64 bit and that is a command line so I can simply write "script-name directory\list-subdirectories-from-NOT-deleting" (so that it automatically deletes the remaining subdirectories and their files with any attribute).THANKSBYE Edited June 12, 2009 by balubeto
balubeto Posted June 13, 2009 Author Posted June 13, 2009 In other words, if I have the structure: Folder1 --- SubFolder1 --- SubFolder2 --- SubFolder3 --- SubFolder4 I would need to write, from the command line: "delete-script / Folder1 / SubFolder1 / SubFolder2" and, therefore, the resulting structure should be: Folder1 - --- SubFolder1 --- SubFolder2 Now, you have realized What is my problem? So how can I do this script?THANKSBYE
Tripredacus Posted June 15, 2009 Posted June 15, 2009 I understood what you meant before and I can imagine the flow of such a program. However I haven't the time to develop a program for you. Sooner or later you are going to have to learn how to write scripts yourself, you make it very far if you refuse to learn this. My recommendation would be to start looking at AutoIT or KIXtart, which are both fairly easy scripting languages. AutoIT should be able to accomplish this, but going onto their forum and requesting them to write you a program might not work out well either.
balubeto Posted June 16, 2009 Author Posted June 16, 2009 (edited) I understood what you meant before and I can imagine the flow of such a program. However I haven't the time to develop a program for you. Sooner or later you are going to have to learn how to write scripts yourself, you make it very far if you refuse to learn this. My recommendation would be to start looking at AutoIT or KIXtart, which are both fairly easy scripting languages. AutoIT should be able to accomplish this, but going onto their forum and requesting them to write you a program might not work out well either.I did a cmd script that should delete all the directories on a hard drive except the subdirectories of the Users\[Name-user-accounts] directory.This script is: pushd "%1"for %%I in (C D E F G H I J K L M N O P Q R S T U V W Y Z) do if exist %%I:\Users set DVDDrive=%%Ifor /D %%f in (%DVDDrive%\*) do ( if /i not "%%f" == "%DVDDrive%\Users\*" rd /s /q "%%f" )popdThis script, run in Windows PE 2.1 on the virtual drive X, do not cancel, however, the system or hidden directories. So how do I change this script to delete these directories?THANKSBYE Edited June 16, 2009 by balubeto
Tripredacus Posted June 16, 2009 Posted June 16, 2009 you might want to play with the attribute flag, in which you can specify file types. examples:/a:s = system files/a:h = hidden files/a:sh = hidden system filesetcThis works with the dir command as well.
balubeto Posted June 19, 2009 Author Posted June 19, 2009 (edited) HIPutting in X virtual disk of Windows PE 2.1 this script, it should delete all files and all directories of an NTFS partition in which there is the \Users directory except this directory and its subdirectories. @echo off for %%I in (C D E F G H I J K L M N O P Q R S T U V W Y Z) do ( if exist %%I:\Users set DVDDrive=%%I else ( echo not exist the %%I:\Users directory. pause goto :EOF) ) pushd X:\Windows\System32 for /R %%f in (%DVDDrive%\) do ( if not "%%f" == "%DVDDrive%\Users" (attrib -rhsi *.* /s del /s /q *.*) ) popdRight or should I make some correction?THANKSBYE Edited June 19, 2009 by Tripredacus Merged topics
SenHu Posted June 24, 2009 Posted June 24, 2009 I recommend using a ? to separate the list of subfolders instead of /. This will allow you to enhance the script later to work at any level of directories. Here is a script in biterscripting.# Script delete.txt# Input argumentsvar str dir # Directory fro where to deletevar str dont # List of subfolders not to delete, separated by ?# Get a list of all subfolders in $dir.var str list; lf -n "*" $dir ($ftype=="d") > $list# Process each subfolder one by onewhile ($list <> "")do # Get the next subfolder from the list. var str subfolder; lex "1" $list > $subfolder # $subfolder now contains the full path of subfolder var list name; stex -p "^/^l[" $subfolder > $name # $name contains only the name of the subfolder # Is this name in the list of not-to-delete $list ? if ( { sen ("^"+$name+"^") $dont } <= 0 ) # This subfolder is not in the list of not-to-delete subfolders. Delete it. system delete ("\""+$subfolder+"\"") endifdoneThis script will work in all Windows versions. I haven't tested it, so test it first. To test,1. Save the script in, say, C:\delete.txt.2. Install biterscripting from http://www.biterscripting.com or any other site you can google up. It's free.3. Start biterscripting. Run the delete.txt script with the following command.script "C:\delete.txt"That's it.Sen
balubeto Posted June 25, 2009 Author Posted June 25, 2009 I recommend using a ? to separate the list of subfolders instead of /. This will allow you to enhance the script later to work at any level of directories. Here is a script in biterscripting.# Script delete.txt# Input argumentsvar str dir # Directory fro where to deletevar str dont # List of subfolders not to delete, separated by ?# Get a list of all subfolders in $dir.var str list; lf -n "*" $dir ($ftype=="d") > $list# Process each subfolder one by onewhile ($list <> "")do # Get the next subfolder from the list. var str subfolder; lex "1" $list > $subfolder # $subfolder now contains the full path of subfolder var list name; stex -p "^/^l[" $subfolder > $name # $name contains only the name of the subfolder # Is this name in the list of not-to-delete $list ? if ( { sen ("^"+$name+"^") $dont } <= 0 ) # This subfolder is not in the list of not-to-delete subfolders. Delete it. system delete ("\""+$subfolder+"\"") endifdoneThis script will work in all Windows versions. I haven't tested it, so test it first. To test,1. Save the script in, say, C:\delete.txt.2. Install biterscripting from http://www.biterscripting.com or any other site you can google up. It's free.3. Start biterscripting. Run the delete.txt script with the following command.script "C:\delete.txt"That's it.SenCan I convert this script into a cmd script so that Vista can run it directly? If so, how do I do this?THANKSBYE
SenHu Posted December 17, 2009 Posted December 17, 2009 Can I convert this script into a cmd script so that Vista can run it directly? If so, how do I do this?Yes, you can run the script directly from Vista command prompt by entering the following command at the command prompt."C:\biterScripting\biterScripting.exe" "C:\delete.txt"You can also schedule this same command in task scheduler if needed.
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now