Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Delete is deleting the whole directory instead of individual files

Tags:

batch-file

cmd

I'm running a simple batch file which is generated by a vbscript to delete individual files, however when I execute it, it is deleting entire subdirectories. Anyone have any ideas on this? Below is the batch file.

rem 2008-12-15D:\DP-Production\Administrative\BUSINESS\FileLink
del D:\DP-Production\Administrative\BUSINESS\FileLink\.-1003067260  /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\.-997208891  /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\.-998224323  /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\._proofing.pdf  /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\._Sample1.pdf  /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\._Shortcut (2) to PDFProofs.lnk  /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\._Shortcut to Art.lnk  /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\._Shortcut to Filelink on 'Admin-srv' (I).lnk  /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\._Shortcut to LeadGen program.lnk  /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\._Shortcut to Mail.lnk  /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\._Shortcut to Maintained on 'Data Pro (Pmi41)' (H).lnk  /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\._Shortcut to Openjobs on 'SRV-srv02' (J).lnk  /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\._SHRP.pdf  /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\._skyphone2.bmp  /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\._Smokey Bones Solo_Mailer.pdf  /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\._steakhouseback.pdf  /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\._steakhousefront.pdf  /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\._Summercamp.pdf  /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\._taxsampleback.pdf  /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\._taxsamplefront.pdf  /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\._Temporary Items  /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\._Beta.pdf  /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\._Trurdy.pdf  /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\._Trash  /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\._trishwenrick.pdf  /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\._Tulane.pdf  /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\._valpak_price.mdb  /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\._WasteM.jpg  /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\weekly_deletions.vbs  /q/f
rem 2008-12-15D:\DP-Production\Administrative\BUSINESS\FileLink\Art
del D:\DP-Production\Administrative\BUSINESS\FileLink\Art\._+.pdf  /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\Art\._0805_NJGolf 12-44-24.pdf  /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\Art\._806857.eps  /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\Art\._ADPLogo.JPG  /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\Art\._FranchiseLtr_MM.doc  /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\Art\._REPAIR-SMA.doc  /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\Art\._Safety.pdf  /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\Art\._Summer 2008 Donor V1.pdf  /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\Art\desktop.ini  /q/f
rem 2008-12-15D:\DP-Production\Administrative\BUSINESS\FileLink\Mail
del D:\DP-Production\Administrative\BUSINESS\FileLink\Mail\ BOBBSS    LIST COUNT - DRIBOX 2008-06 ejs.msg  /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\Mail\#7608 GHA MD Mailing.ZIP  /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\Mail\2008 Adel List.xls  /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\Mail\2008 mailing-BREAK OUT.xls  /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\Mail\2008 Password Letter to GM (R).doc  /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\Mail\2008 RL Mailing.xls  /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\Mail\2008DLRCRICKPage1.pdf  /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\Mail\805026.pdf  /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\Mail\805442_Breakfast.pdf  /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\Mail\806330_Letter.pdf  /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\Mail\806778.pdf  /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\Mail\806785 JONES WORLD VIEW DHL.xls  /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\Mail\807364-807117.csv  /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\Mail\8522435_INTDELIVERY.zip  /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\Mail\8674252_INTDELIVERY.zip  /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\Mail\8674856_INTDELIVERY.zip  /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\Mail\8675351_INTDELIVERY.zip  /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\Mail\8694521_INTDELIVERY.zip  /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\Mail\8720608_INTDELIVERY.zip  /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\Mail\8cletoy0903_1.csv  /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\Mail\8roncar0657.csv  /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\Mail\8vanhyu0531.zip  /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\Mail\addressfile0605.xls  /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\Mail\All Active Employee Address 070808.xls  /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\Mail\APPA_Mailing_List-FINAL-XLS4.xls  /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\Mail\Aug 08 Coupon Data.txt  /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\Mail\BMA.pdf  /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\Mail\BODYCOPY.doc  /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\Mail\BOISE JUNE SALON MASTER LIST rev 6-9-08 (6).xls  /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\Mail\Broward Committe REVISED.xls  /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\Mail\CAW Tournament Letter (2).doc  /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\Mail\detroit lasalle delete list.xls  /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\Mail\CHIROPRACTOR 300.xls  /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\Mail\CMTFV08204macroed.bak  /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\Mail\Comm Ltr#2.doc  /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\Mail\Contact Directory.rtf-MA  /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\Mail\Copy of Jones Newsletter 0708.xls  /q/f
del D:\DP-Production\Administrative\BUSINESS\FileLink\Mail\Copy of MD L-Listing 07_11_08.xls  /q/f
like image 295
phill Avatar asked Nov 29 '22 07:11

phill


2 Answers

Put filenames between double quotes... (e.g. "D:\My Program\test.exe")

like image 121
Vincent Van Den Berghe Avatar answered Dec 06 '22 08:12

Vincent Van Den Berghe


I'm going to assume it is because of this line:

del D:\DP-Production\Administrative\BUSINESS\FileLink\Mail\ BOBBSS    LIST COUNT - DRIBOX 2008-06 ejs.msg  /q/

Notice the space there, it says: Delete everything in that folder, then delete the file called BOBBSS, then the file called LIST, then the file called COUNT, then ... uhm, error, then the file called DRIBOX, etc.

Do what Vincent Van Den Berghe says, use " around the filenames.

like image 35
Lasse V. Karlsen Avatar answered Dec 06 '22 10:12

Lasse V. Karlsen