Timed defragmentation on folders

User avatar
ChrisGreaves
PlutoniumLounger
Posts: 15641
Joined: 24 Jan 2010, 23:23
Location: brings.slot.perky

Timed defragmentation on folders

Post by ChrisGreaves »

A quick Google search does not reveal (to me) an effective (i.e. Command-line) way of defragmenting folders.

I am not a big fan of defragmentation, but the occasional use of the analysis in Defraggler reveals that I have many fragmented folders.

Since a folder/directory is the gateway to all files, I would consider defragmenting one or more folders on a regular basis, where "regular" might be defined as:-
(1) Fixed schedule e.g. 11pm each evening
(2) Trigger event e.g. at the exit from my Word2003 batch file
(3) Spontaneous event e.g. an executed batch file by the user

I envisage a command line of the form:-

Code: Select all

cmd.exe /c defrag t:\Greaves\products /D /s 
which would defragment the Directories (but not the individual files) in the tree of folders held by T:\Greaves\Products

Thanks
Chris
He who plants a seed, plants life.

jstevens
GoldLounger
Posts: 2631
Joined: 26 Jan 2010, 16:31
Location: Southern California

Re: Timed defragmentation on folders

Post by jstevens »

Chris,

Have you considered using a batch file to run the defrag? You then can use the Task Scheduler to run the batch file set to the day/time you want to it to run. If you want to run it on demand then just run the batch file.

I'm not sure how to do it upon exiting Word.
Regards,
John

User avatar
HansV
Administrator
Posts: 78567
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Timed defragmentation on folders

Post by HansV »

You might like the free Contig utility from Microsoft.
Best wishes,
Hans

User avatar
ChrisGreaves
PlutoniumLounger
Posts: 15641
Joined: 24 Jan 2010, 23:23
Location: brings.slot.perky

Re: Timed defragmentation on folders

Post by ChrisGreaves »

jstevens wrote:Have you considered using a batch file to run the defrag?...I'm not sure how to do it upon exiting Word.
Thanks John.
Just about everything I run is run from a batch file.
I have run a de-fragmented from a batch file in the past, but am not in love with defragmentation now.
Defragmentation of a folder is to my mind a different thing.
(1) Folders are the critical gateway to files and
(2) I have a feeling that forcing a load-to-memory of all regular folders might serve as a type of pre-fetch.

By Word2003 is run from a batch file (attached) so it is dead easy to splice in a command line once WinWord.exe exits back to the batch file.
Cheers
Chris
You do not have the required permissions to view the files attached to this post.
He who plants a seed, plants life.

User avatar
ChrisGreaves
PlutoniumLounger
Posts: 15641
Joined: 24 Jan 2010, 23:23
Location: brings.slot.perky

Re: Timed defragmentation on folders

Post by ChrisGreaves »

HansV wrote:You might like the free Contig utility from Microsoft.
Thank You Hans.
I gave it a quick try a week ago, but didn't give it a fair trial. I'll try it again Monday.
Cheers
Chris
He who plants a seed, plants life.

User avatar
ChrisGreaves
PlutoniumLounger
Posts: 15641
Joined: 24 Jan 2010, 23:23
Location: brings.slot.perky

Re: Timed defragmentation on folders

Post by ChrisGreaves »

HansV wrote:You might like the free Contig utility from Microsoft.
Contig seems not to work, but reports that it does.
Contig01.png
The screen snapshot shows two consecutive runs of contig against a single file, infamous spreadsheet of 18 fragments of a couple of months ago.
Each run reports 69 fragments per file. ( Win7HP.)

This is, as you have guessed, not a critical issue, but I wonder if anyone reading this can confirm that my command-line statement is correct.

Drive T: is a Truecrypt(ed) drive.

Thanks
Chris
You do not have the required permissions to view the files attached to this post.
He who plants a seed, plants life.

User avatar
HansV
Administrator
Posts: 78567
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Timed defragmentation on folders

Post by HansV »

The command line looks OK. Apparently contig has decided that the file cannot/should not be defragmented...

CCleaner's Defraggler also has a command line utility: Command-line parameters
Defraggler comes with a command-line version of the GUI program called df.exe. This program is located in the same folder as defraggler.exe, typically C:\Program Files\Defraggler.
Best wishes,
Hans

User avatar
ChrisGreaves
PlutoniumLounger
Posts: 15641
Joined: 24 Jan 2010, 23:23
Location: brings.slot.perky

Re: Timed defragmentation on folders

Post by ChrisGreaves »

HansV wrote:CCleaner's Defraggler also has a command line utility:
Thank you, Hans.

Code: Select all

Defragments the specified file or folder. You can chain multiple <items> together, but they all must be located on the same drive.
For a specified folder, Defraggler will also defragment any subfolders beneath it (recursive).
This looks promising. I shall set up a trial later and see how it copes with folders on a drive.

Cheers
Chris
He who plants a seed, plants life.