Jump to content

Batch Files?


mstester

Recommended Posts


Thanks everyone, it the switch /s worked like a dream!

Thanks again guys!

The correct switch is /p. for more information type DEL/? at command prompt. As explained /s will continue deleting the named file from all subdirectories (and will search for it, taking up time and resources!)
Link to comment
Share on other sites

The correct switch is not /P or /S for that matter!

If you use del at the command line or in a cmd file you will not be asked for confirmation on a single file in these scenarios; hidden, system or read-only.

If the file is hidden or a system file you will get the following message:

Could Not Find X:\SomePath\SomeFile.ext

If the file is read only you will get the following message:

Access is denied

The correct switches to use if you want to get rid of a single file without returning either of the two messages is:

del/a/f X:\SomePath\SomeFile.ext

Link to comment
Share on other sites

The correct switch is not /P or /S for that matter!

If you use del at the command line or in a cmd file you will not be asked for confirmation on a single file in these scenarios; hidden, system or read-only.

Well I think we can assume he doesn't want to delete hidden, read only or system files - if he does then that's another matter... there is a reaon for those file attributes, you know!
Link to comment
Share on other sites

Plamdi,

maybe you got it wrong:

1) mstester does NOT want a prompt for deleting file(s)

2) normally there is NO prompt when deleting a single file UNLESS it is either a Read Only or System file:

2a) If it is Read Only, the prompt will be "Access Denied"

2b) If it is System, the prompt will be "Cannot find file"

3) if you are deleting MORE than one file, using a wild card, like in del *.*, a prompt will come out asking whether you want to proceed

So, the /s will do the same command in each subdirectory, but if you use wildcards, you will be prompted once for each subdirectory.

The /q suppresses the prompt generated by MULTIPLE deletes (i.e. using wildcards)

the /p will FORCE the (unwanted) prompt for EACH file.

the /f forces the deleting of Read Only files

the /a (optionally followed by the type of attribute) will allow deleting files with particular attributes, /ar is the same as /f, /a means every file but those that are Read Only

So, if you want to delete files with NO prompt whatsoever, the right syntax is

del /a /f

If, from a batch file or from command line you want to bypass the prompt generated by a wildcard, without pressing S (Y in English) you use:

echo S | del \dir\*.*

i.e. you pipeline a "S" or a "Y" into the command.

If you use the /s parameter, of course only first prompt will be bypassed, this can be useful in some occasion INSTEAD of the /q.

jaclaz

Edited by jaclaz
Link to comment
Share on other sites

The correct switch is not /P or /S for that matter!

If you use del at the command line or in a cmd file you will not be asked for confirmation on a single file in these scenarios; hidden, system or read-only.

Well I think we can assume he doesn't want to delete hidden, read only or system files - if he does then that's another matter... there is a reaon for those file attributes, you know!

For no reason other than to kick a man when he's down...

There is no switch to remove a prompt that you do not get!

You can get prompts for wildcard deletions.

i.e.

del *.txt

In these cases they are not single files, they are 'global wildcards' and will therefore require the /q switch for supression of the resulting prompt(s).

i.e.
del/q *.txt

Link to comment
Share on other sites

the /a (optionally followed by the type of attribute) will allow deleting files with particular attributes, /ar is the same as /f, /a means every file but those that are Read Only

jaclaz

/AR

how is this actually written in practice please? i.e. spacing and colon :

e.g.

/A : R

/A:R

/A: R

/A :R

...etc.

Cheers!

;)

Link to comment
Share on other sites

This is not an entire list, but I hope it answers your question!

DEL/AR		DEL /AR		_
DEL/ARH DEL /ARH |
DEL/ARHS DEL /ARHS |
DEL/ARS DEL /ARS |
DEL/A:R DEL /A:R All these will delete a single file with a read only attribute, regardless of its system or hidden staus.
DEL/A:RH DEL /A:RH |
DEL/A:RHS DEL /A:RHS |
DEL/A:RS DEL /A:RS |
DEL/A/F DEL /A/F ¯

Link to comment
Share on other sites

@ Yzowl

thanks for the info!! :thumbup

Also:

Windows XP syntax

Deletes one or more files.

DEL [/P][/F] [/Q] [/A[[:]attributes]] names

ERASE [/P] [/F] [/Q] [/A[[:]attributes]] names

names Specifies a list of one or more files or directories. Wildcards may be used to delete multiple files. If a directory is specified, all files within the directory will be deleted.

/P Prompts for confirmation before deleting each file.

/F Force deleting of read-only files.

/S Delete specified files from all subdirectories.

/Q Quiet mode, do not ask if ok to delete on global wildcard

/A Selects files to delete based on attributes

attributes R Read-only files S System files

H Hidden files A Files ready for archiving

- Prefix meaning not

If Command Extensions are enabled DEL and ERASE change as follows:

The display semantics of the /S switch are reversed in that it shows you only the files that are deleted, not the ones it could not find.

"If Command Extensions are enabled "

...could you explain/define what is meant by this statement please? [thanks].

:wacko:

I know what file extensions are, but not command extensions?

I've googled "what are command extensions?" and "command extensions explained" and "command extensions" but no immediate answer seems to be available. Microsoft talk about command extensions but without explaining exactly what they are? :no:

Edited by the_doc735
Link to comment
Share on other sites

"If Command Extensions are enabled "

...could you explain/define what is meant by this statement please? [thanks].

Command Extensions are enabled by default. You may also disable

extensions for a particular invocation by using the /E:OFF switch. You

can enable or disable extensions for all invocations of CMD.EXE on a

machine and/or user logon session by setting either or both of the

following REG_DWORD values in the registry using REGEDT32.EXE:

HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\EnableExtensions

and/or

HKEY_CURRENT_USER\Software\Microsoft\Command Processor\EnableExtensions

to either 0x1 or 0x0. The user specific setting takes precedence over

the machine setting. The command line switches take precedence over the

registry settings.

Type "cmd /?" for details.

Link to comment
Share on other sites

Command Extensions are enabled by default

They might be enabled by default, BUT WHAT ARE THEY PLEASE?

[example answer] Command extensions are......

i.e. that's like saying a chef uses a frying pan.

A chef may use a frying pan, but what is it?

A shallow, long-handled, circular metal container, usually 8, 10 and 12 inches in diameter; used for frying food. Also called skillet; also called regionally fry pan, spider.

Hope you understand me better now? :blink:

many thanks!

Edited by the_doc735
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...