Scan a directory (and sub-directories) and delete some files

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
ssaucsw
Posts: 2
Joined: 04 Oct 2010 22:06

Scan a directory (and sub-directories) and delete some files

#1 Post by ssaucsw » 04 Oct 2010 22:15

Hi Guys,

I use a central NAS system at home. I have two computers connecting to it. One is a Windows 7 machine, and the other is a MacBook Pro.

Whenever I add to or browse the NAS, it leaves hidden folders called ".AppleDouble" which is hidden, and sometimes a file called ".DSSTORE" or something-or-rather.

I was after a batch file which scans a main directory folder and its sub-directories. ie "z:\school work" (which has sub-directories like "mathematics, english, etc" and delete any ".AppleDouble" files located in any folder.

Is this possible?

Kind regards, and thanks in advance

amel27
Expert
Posts: 177
Joined: 04 Jun 2010 20:05
Location: Russia

Re: Scan a directory (and sub-directories) and delete some f

#2 Post by amel27 » 04 Oct 2010 22:53

Code: Select all

del /f/s/q/ah "z:\school work\.AppleDouble"

ssaucsw
Posts: 2
Joined: 04 Oct 2010 22:06

Re: Scan a directory (and sub-directories) and delete some f

#3 Post by ssaucsw » 05 Oct 2010 03:01

Hi amel27,

Thanks for your quick reply.

Does that piece of code scan all sub-directories as well as the main directory? Sorry if it seems obvious, but I'm a bit rusty when it comes to batch/dos files.. Haven't played around with them in about 10 years.

So in other words:
Z:\school work\.AppleDouble
Z:\school work\maths\.AppleDouble
Z:\school work\english\.AppleDouble
etc..?

And also, would the script terminate if it scans a file and does not find the .AppleDouble file? Or would it just continue?

Thanks again..

amel27
Expert
Posts: 177
Joined: 04 Jun 2010 20:05
Location: Russia

Re: Scan a directory (and sub-directories) and delete some f

#4 Post by amel27 » 05 Oct 2010 03:21

yes, switch /s enable search selected file in root folder and subfolders, switch /h find only hidden files... if hidden attribute may set or not, command syntax:

Code: Select all

del /f/s/q/a "z:\school work\.AppleDouble"

Post Reply