The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Special Forums > Windows & DOS: Issues & Discussions
.
google unix.com



Windows & DOS: Issues & Discussions All Windows and DOS questions should go here as well. Discuss UNIX to Windows (Desktop or Server) here!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
find and replace command in one line using one command vasikaran UNIX for Dummies Questions & Answers 10 08-20-2008 10:40 AM
assign a command line argument and a unix command to awk variables sweta_doshi Shell Programming and Scripting 0 08-08-2008 06:54 AM
how to? launch command with string of command line options TinCanFury Shell Programming and Scripting 5 04-28-2008 06:06 PM
how to tell which OS via command line hankooknara UNIX for Dummies Questions & Answers 4 05-15-2007 11:39 PM
Command line... laila63 Shell Programming and Scripting 15 07-14-2004 03:37 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 10-19-2008
Killalot57 Killalot57 is offline
Registered User
  
 

Join Date: Oct 2008
Posts: 8
Command line help please

Hello, I'm making a batch command to delete all the files in my "recent files" folder. At first I set it up so that it would create a .txt file in there, then delete all the files in there, so that I wouldn't get an error message when I ran it. Here is what I had...

@echo off
echo.>"C:\Documents and Settings\James\Recent\"file.txt
del /q "C:\Documents and Settings\James\Recent\*.*"
ECHO Arg, I'm getting Tired Of Making These!
ECHO.
PAUSE

What I'd like to do is have a command that will only tell it to delete the files there is one exist. So I tried the following command line in a different batch command.

@echo off
if exist "C:\Documents and Settings\James\Recent\*.*" del /q "C:\Documents and Settings\James\Recent\*.*"
echo hi everyone
echo.
PAUSE

I get most of my command lines from friends and random internet people, so I can't really figure out what to change myself. I tried a few variations but I haven't been getting anywhere...
  #2 (permalink)  
Old 10-19-2008
radoulov's Avatar
radoulov radoulov is offline Forum Staff  
addict
  
 

Join Date: Jan 2007
Location: Варна, България / Milano, Italia
Posts: 2,847
Moving to Windows & DOS.
  #3 (permalink)  
Old 10-21-2008
joeyg's Avatar
joeyg joeyg is offline Forum Staff  
modérateur
  
 

Join Date: Dec 2007
Location: Home of 17-time world champion Boston Celtics
Posts: 1,311
Wink What about the following?

Code:
IF EXIST filename. (
  del filename.
  ) ELSE (
  echo filename. missing.
)
  #4 (permalink)  
Old 10-22-2008
Killalot57 Killalot57 is offline
Registered User
  
 

Join Date: Oct 2008
Posts: 8
Joeyg! it worked, but now it asks me if I'm sure if I want to delete the file (y/n).... Is there a way to disable this from popping up? so it just deletes the files without confirmation?
  #5 (permalink)  
Old 10-22-2008
joeyg's Avatar
joeyg joeyg is offline Forum Staff  
modérateur
  
 

Join Date: Dec 2007
Location: Home of 17-time world champion Boston Celtics
Posts: 1,311
Wink There are some options.

I am guessing that the files are marked read-only if you are getting a prompt to make sure you want to delete. Some of the delete options are:

/P to confirm (prompt) delete
/F to force delete read-only files
/Q quiet mode, do not confirm with wildcards

Take a look at the following website that has a fairly extensive description for most DOS commands --
MS-DOS help and commands
  #6 (permalink)  
Old 10-22-2008
Killalot57 Killalot57 is offline
Registered User
  
 

Join Date: Oct 2008
Posts: 8
Hi everyone!
Special thanks to:joeyg
I changed the command from...

@echo off
if exist "C:\Documents and Settings\James\Recent\*.*" del /q "C:\Documents and Settings\James\Recent\*.*"
echo hi everyone
echo.
PAUSE

to...

@echo off
if exist "C:\Documents and Settings\James\Recent\*.*" del "C:\Documents and Settings\James\Recent\*.*" /Q
echo hi everyone
echo.
PAUSE

And it workes perfectly! thank-you
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 04:12 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0