PDA

View Full Version : How to Prevent Deletion of Empty Folders


armsys
27-Jun-2009, 06:39 AM
The following script will delete all empty folders as well files matching the "~*.*" criteria.
load "C:\MyFolder"
filter "~*.*"
select lt

Question:
How to prevent deletion of empty folders?

Armstrong

Chris
27-Jun-2009, 09:43 AM
Hi Armstrong,

Change your selection command from "select lt" to "select lt.files". If you issue a delete command, this will only delete files and leave empty folders behind.

armsys
29-Jun-2009, 05:36 AM
Chris,
It's nice to see your reply. I tested your suggested command, but it fails. It fails because none of files matching the "~*.*" are deleted, surprisingly! BTW, the C:\ArmSys\MindManager folder contains only subfolders. All "~*.* files populate in the subfolders.
#************************************************* *********************#
# Mindmanager Maps
load "C:\ArmSys\MindManager"
filter "~*.*"
select lt.files
delete recyclebin=yes left
#************************************************* *********************#
Thanks.
Armstrong

Aaron
01-Jul-2009, 03:07 PM
Hello,

You need an expand all statement in there :) Try:

filter "~*.*"
load "C:\ArmSys\MindManager"
expand all
select lt.files
delete recyclebin=yes left

armsys
01-Jul-2009, 07:56 PM
Hi Aaron,
Yes, thanks for pinpointing the cause of the problem.
I appreciate your sample script which is very helpful.

Two more questions:
1. Should the Filter command follow Load command?
2. Is Filter command additive?
filter "*.pas;*.dpr;*.dfm"
filter cutoff:>"Jan 1, 2001"
filter attrib:-sh

Will the 3 filters be applied simultaneously?
Must the 3 filters be written in a single line?

Armstrong

Aaron
02-Jul-2009, 02:44 PM
Hello,

Filters before load will prevent those files from comparing when loaded. It will make your script a bit faster.

filter is not additive. The example given in the Help File: Script Reference is:
filter "*.txt;-Recycle Bin\" attrib:+r

Each call to the filter command replaces the current filter.

armsys
02-Jul-2009, 03:46 PM
Hi Aaron,
Thanks for clarifying the nuance of using the script commands.
Armstrong

Aaron
02-Jul-2009, 04:18 PM
You're welcome. :)

Let us know if you have any other questions.