Nifty batch script to purge unnecessary files and folders...

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
Noisia
Posts: 2
Joined: 25 Jun 2014 13:02

Nifty batch script to purge unnecessary files and folders...

#1 Post by Noisia » 25 Jun 2014 13:16

Hi!

I'm managing to create a script to purge unnecessary files from my music folders. I've managed to make it work when embedded in respective folder but i aim to create a exe file and run it from right-click menu.
I reckon this script is flawed and it only works well in *.bat format. As soon as i convert to exe it only works partially.

The code follows:

Code: Select all

for %%g in (*.jpg,*.jpeg,*.m3u,*.m3u8,*.cue,*.sfv) do if not %%g == folder.jpg recycle %%g

for /d /r . %%d in (scans,covers,video,technical) do @if exist "%%d" recycle "%%d"


I need to complete it but i lack the knowledge. Is anybody willing to help me please? :)

Thank you in advance!

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Nifty batch script to purge unnecessary files and folder

#2 Post by foxidrive » 26 Jun 2014 00:52

What is the recycle command?

You need to explain what you are trying to do.

Noisia
Posts: 2
Joined: 25 Jun 2014 13:02

Re: Nifty batch script to purge unnecessary files and folder

#3 Post by Noisia » 26 Jun 2014 06:06

My apologies for not being succinct on that. I have "recycle.exe" located in my windows folder enabling me to use "recycle" command instead of permanently deleting files using "del" command.

What i'm trying to achieve is simple:

1- Recycle all files containing the following extensions: *.jpg,*.jpeg,*.m3u,*.m3u8,*.cue,*.sfv.
2- Recycle all folders that match the following names: scans,covers,video,technical.
3- If there is "folder.jpg" inside the directory, keep it.

I also want to convert this batch script to a EXE file and run it from the main directory to purge all sub-directories.

Let's say i have a directory called "Jimmy Hendrix" and his albums as sub-direcories. I want to be able to right click Jimmy Hendrix and purge every sub-directory by running a exe file.
Last edited by Noisia on 27 Jun 2014 09:22, edited 1 time in total.

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Nifty batch script to purge unnecessary files and folder

#4 Post by foxidrive » 26 Jun 2014 08:52

This will remove those filetypes from the current folder and below.

Code: Select all

del /s *.jpg *.jpeg *.m3u *.m3u8 *.cue *.sfv

Post Reply