Balubeto Balubeto
Jun 12 2009, 02:30 AM
HI
I 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.
THANKS
BYE
jaclaz
Jun 12 2009, 03:01 AM
And what is the question?

If it is "what should I use to write this script?" the answer is that a simple batch is enough.
jaclaz
Balubeto Balubeto
Jun 12 2009, 03:20 AM
QUOTE (jaclaz @ Jun 12 2009, 10:01 AM)

And what is the question?

If it is "what should I use to write this script?" the answer is that a simple batch is enough.
jaclaz
So, how do I make this bat file?
THANKS
BYE
bengt
Jun 12 2009, 04:00 AM
QUOTE (Balubeto Balubeto @ Jun 12 2009, 10:20 AM)

So, how do I make this bat file?
THANKS
BYE
open a text editor of your choice and start typing...save it as .cmd or .bat <<< link
Balubeto Balubeto
Jun 12 2009, 11:08 AM
QUOTE (bengt @ Jun 12 2009, 11:00 AM)

The problem is what I not am capable of programming.
So, I'm looking for someone willing to do this simple script.
THANKS
BYE
hilander999
Jun 12 2009, 12:08 PM
QUOTE
except those mentioned by me.
Explain what this means.
Your wanting to hard code an exclusion list into the script, or something else?
Are you wanting it to remove directories from a drive root or use a drag&drop approach?
Balubeto Balubeto
Jun 12 2009, 12:53 PM
QUOTE (hilander999 @ Jun 12 2009, 07:08 PM)

Explain what this means.
Your wanting to hard code an exclusion list into the script, or something else?
Are you wanting it to remove directories from a drive root or use a drag&drop approach?
So, 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).
THANKS
BYE
hilander999
Jun 12 2009, 01:20 PM
the problem with that theory is that if you mistype something the data is just gone.
A list or some type of confirmation would be safer.
How many layers down are you wanting the exclusion to work?
bengt
Jun 12 2009, 01:32 PM
You could create a script where you make the files you want to exclude read-only.
DEL /S will not delete read-only files.
then adapt the script to ignore sub-folders and all files of a given type:
attrib /S *.zzz +r
Balubeto Balubeto
Jun 13 2009, 11:40 AM
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?
THANKS
BYE
paraglider
Jun 13 2009, 02:14 PM
All you need is:
rd /s /q <directory to delete>
Balubeto Balubeto
Jun 14 2009, 02:51 AM
Here is a batch file that removes from the ram drive all directories that don't start with 'Documents and Settings'. You should be able to amend it to fit your exact requirements:
for /D %%f in (%ramdrv%\*) do ( if /i not "%%f" == "%ramdrv%\Documents And Settings" rmdir /s /q "%%f" )
so for example assuming the root directory is passed in as the parameter:
QUOTE
pushd "%1"
for /D %%f in (*) do ( if /i not "%%f" == "folder1" ( if /i not "%%f" == "folder2" rmdir /s /q "%%f") )
popd
Ed_P
Jun 14 2009, 10:25 PM
FWIW If the folders to be kept were uniquely named, for example they all started with an ! or an @ then the exclusion test could be simpler.
Balubeto Balubeto
Jun 16 2009, 04:58 AM
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:
CODE
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=%%I
for /D %%f in (%DVDDrive%\*) do ( if /i not "%%f" == "%DVDDrive%\Users\*" rd /s /q "%%f" )
popd
This 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?
THANKS
BYE
dog
Jun 16 2009, 05:56 AM
Balubeto Balubeto
Jun 16 2009, 10:39 AM
QUOTE (dog @ Jun 16 2009, 12:56 PM)

Excuse me but where I put this command in my script?
THANKS
BYE
hilander999
Jun 16 2009, 10:58 AM
I hope you realize how dangerous that script you posted is and that it has the potential to wipe out a lot more then what your wanting.
bengt
Jun 16 2009, 11:47 AM
create an exclusion list...i.e. leave only those files which are listed in a text file and delete all others.
paraglider
Jun 16 2009, 06:11 PM
I think the script deletes every directory in the root of the drive which is not what was required. If should be:
if /i not "%%f" == "%DVDDrive%\Users"
so that at Least Users is left.I would have thought you would also want to leave your windows directory.
Balubeto Balubeto
Jun 17 2009, 03:06 AM
HI
Someone can write me a script that deletes all directories (including the system and hidden directories) of an hard-disk except those that belong to a list of specific directories in the subdirectory \Users\*\ ?
Unfortunately, I'm not a programmer and I do not know how to write this script.
THANKS
BYE
bengt
Jun 17 2009, 04:57 AM
sounds like a virus....
why don't you copy the stuff you want to another drive and then do a format?? much easier...
Balubeto Balubeto
Jun 17 2009, 06:18 AM
QUOTE (bengt @ Jun 17 2009, 11:57 AM)

sounds like a virus....
why don't you copy the stuff you want to another drive and then do a format?? much easier...
No virus.
I created a custom installation of Vista SP1 that puts the directory Users\Account-name\ in another partition D.
Now, because, during installation of some programs are created some directories in the D partition and especially in the directory Users\Account-name\, I would delete all these directories before I re-install Vista SP1 on the C system partition. Now, you understand? So, can someone write this script?
THANKS
BYE
paraglider
Jun 17 2009, 06:25 AM
No. Don't understand. How often do you reinstall Vista that you need to automate the deletion process. Why not just delete the folders manually with explorer or whatever file manager you use.
jaclaz
Jun 17 2009, 07:03 AM
QUOTE (Balubeto Balubeto @ Jun 17 2009, 10:06 AM)

Unfortunately, I'm not a programmer and I do not know how to write this script.
You don't need to be a programmer to write a batch.
You should just have some familiarity with using command line, and read/learn a bit about BATCH language.
You do know what BATCH means, do you?
Meaning three:
http://www.thefreedictionary.com/batchA BATCH script is just a way to repeat the steps you do manually, automating all of them in a sequence of commands.
Here is a good resource to start with:
http://www.robvanderwoude.com/batchfiles.phphttp://www.robvanderwoude.com/batchstart.phpjaclaz
Balubeto Balubeto
Jun 17 2009, 12:06 PM
QUOTE (paraglider @ Jun 17 2009, 01:25 PM)

No. Don't understand. How often do you reinstall Vista that you need to automate the deletion process. Why not just delete the folders manually with explorer or whatever file manager you use.
I have to create this script to automate this process as I will have to distribute to my customers a personalized DVD of Vista including a customized Windows PE 2.1 with this script and they do not know the default directory of the \Users\Account-user\.
So, this script will serve to automatically delete the D partition by all non-default directory to ensure that the contents of the default directory will not be deleted by mistake.
So when my clients have to reinstall Vista SP1 with my DVD, they will find only their default directory with their data.
THANKS
BYE
Ed_P
Jun 17 2009, 05:46 PM

Confused. If you're not a programmer and don't know how to create BAT/CMD files how are you able to create a customized Vista SP1 DVD???
Balubeto Balubeto
Jun 18 2009, 02:28 AM
QUOTE (Ed_P @ Jun 18 2009, 12:46 AM)


Confused. If you're not a programmer and don't know how to create BAT/CMD files how are you able to create a customized Vista SP1 DVD???

Simple, I use Windows AIK to create XML files.
THANKS
BYE
bengt
Jun 18 2009, 03:12 AM

are you related to marine1?
Tic-Tac-Toe anyone??
jaclaz
Jun 18 2009, 06:08 AM
So, you are a professional "IT consultant" AND you have an Agreement with Microsoft allowing redistribution of a "OEM" Vista AND you are not a programmer AND you don't know command line / batch language (relatively easy) and a number of very basic DVD related creation commands:
http://www.boot-land.net/forums/index.php?...ic=8147&hl=http://www.boot-land.net/forums/index.php?...ic=8129&hl=but you do know your way into the WAIK (comparatively extremely difficult) to create modified/unattended/semi-unattended installs.

I would be curious to know how you plan to word the invoice you will be (hopefully

) payed for by your customers.
i.e. will this:
QUOTE (reality)
hours spent on half the internet forums asking people to do work I have no clue about, but that you are going to pay anyway
become:
QUOTE (invoice item)
hours spent on programming custom solutions
OR:
QUOTE (invoice item)
external consultants fees

jaclaz
Tripredacus
Jun 18 2009, 12:12 PM
And as I said else where:
QUOTE
Sooner or later you are going to have to learn how to write scripts yourself, you won't make it very far if you refuse to learn this.
Balubeto Balubeto
Jun 18 2009, 01:56 PM
HI
This script should delete all files and all directories of the partition in which there is the \Users directory except this directory and its subdirectories.
CODE
@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 *.*)
)
popd
Right or should I make some correction?
THANKS
BYE
jaclaz
Jun 19 2009, 01:22 PM
QUOTE (Balubeto Balubeto @ Jun 18 2009, 08:56 PM)

Right or should I make some correction?
It's not that difficult.
Try running it.
If it works it is "Right".
If it does not, it needs some corrections.
jaclaz
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please
click here.