[Help] Batch Script / PS Script ect

smoochy boys on tour

LightBringer

Primordial GM
Veteran
Primordial
Game Master
Feb 13, 2014
3,842
1
1,758
260
Has anyone got a script/batch file that can purge a target folder and all sub folders for any file less than a certain size?

I used to have one that did it at a folder level but not subfolder level.
I'll try have a google of it tomorrow, but thought I'd pick brains here!
 

1PKRyan

LOMCN Developer
Developer
Nov 9, 2007
1,536
149
275
No
I have used something like this in the past:
RSPT4jR.png

Sorry about the fruit salad... Blame 'sublime text'.

Some notes:
1). If you are going to put this inside the root target folder and run it from there you can delete the 'CD' line command.
2). If your working directory is not the 'OS' drive then you need to add '/D' after 'CD' so it will become 'CD /D E:\test_folder\'.
3). I am sure you are well-aware that *.* is the wildcard for any, if you want a specific file-extension then change it. e.g. *.txt.
4). The size variable is in bytes.
5). LEQ ( <= ) is less-than-or-equal. You can also use EQU ( == ) equal, NEQ ( != ) not-equal, LSS ( < ) less-than, GTR ( > ) greater-than GEQ ( >= ) greater-than-or-equal.

Depending on your preferences this .bat file may need altering.

This is a pretty good website for commands, descriptions and usages:
 

Attachments

  • search_and_purge_files_leq_size.rar
    284 bytes · Views: 2
  • Like
Reactions: LightBringer

Buggy

Dedicated Member
Dedicated Member
Oct 10, 2011
14
2
29
A little late to the party but if any issues a bash script (I think works)

target=$1
min_size=$2
find "$target" -type f -size -"$min_size"c -delete