Task 438: .MYD File Format
Task 438: .MYD File Format
File Format Specifications for the .MYD File Format
The .MYD file format is used for MyDefrag scripts, which are text-based files that control defragmentation and optimization tasks in the MyDefrag tool (a free disk maintenance utility for Windows). The format is a simple scripting language for parameter passing, not a full programming language. Scripts are executed line by line, with validation to prevent errors. They support Unicode, UTF-8, or ASCII encoding, ignore whitespace, are case-insensitive, and include comment syntax (block /* */ or line //, REM, #, --). The structure typically includes settings, volume selection blocks, and file action blocks to define zones on disks. Detailed syntax, commands, and parameters are as outlined in the MyDefrag documentation.
1. List of All the Properties of This File Format Intrinsic to Its File System
Based on the script format, the intrinsic properties (settings, commands, parameters, and variables that can be defined and extracted from a .MyD file) are:
- Title: The display name of the script.
- Description: A description of the script's purpose.
- Slowdown: A numeric value (0-100) to control processing speed.
- Debug: A numeric value (0-6) for log detail level.
- WriteLogfile: Enables writing a user-friendly logfile.
- AppendLogfile: Enables appending to an existing logfile.
- RunScript: Calls another script (for chaining or resolution).
- VolumeSelect: Criteria for selecting volumes (e.g., All, CommandlineVolumes).
- VolumeActions: Actions to perform on selected volumes.
- VolumeBoolean: Logical conditions for volume selection.
- VolumeEnd: Ends the volume block.
- FileSelect: Criteria for selecting files (e.g., All, FileName("pattern")).
- FileActions: Actions on selected files (e.g., Defragment, SortByName(Ascending/Descending), FastFill).
- FileBoolean: Logical conditions for file selection.
- FileEnd: Ends the file block.
- Variables: Dynamic values used in the script (STRING, NUMBER, DATETIME).
- Macros: Commandline-defined parameters (NAME=VALUE) for customization.
These properties define how the script interacts with the file system for defragmentation tasks.
2. Two Direct Download Links for Files of Format .MYD
http://file.fyicenter.com/c/sample.myd
https://chomikuj.pl/dawidxziom/MyDefrag+v4.3.1/SystemDiskDaily,1022255803.MyD
3. Ghost Blog Embedded HTML JavaScript for Drag and Drop .MYD File Dump
Here's a self-contained HTML snippet with JavaScript that can be embedded in a Ghost blog (or any HTML page). It creates a drag-and-drop zone where a .MYD file can be dropped, reads the file as text, parses the properties (commands and parameters), and dumps them to the screen in a readable format.
This script parses simple command (property) lines like Title("My Script") or Slowdown(80) and displays them. It ignores comments and whitespace.
4. Python Class for .MYD File
import re
class MydFileHandler:
def __init__(self, filename):
self.filename = filename
self.properties = {}
def read_and_decode(self):
with open(self.filename, 'r', encoding='utf-8') as f:
text = f.read()
lines = text.split('\n')
for line in lines:
line = line.strip()
if line and not line.startswith(('//', 'REM', '#', '--')):
match = re.match(r'(\w+)\s*\((.*)\)', line)
if match:
key, value = match.groups()
self.properties[key] = value.strip('"\'')
elif re.match(r'^\w+$', line):
self.properties[line] = '(no parameters)'
def print_properties(self):
for key, value in self.properties.items():
print(f"{key}: {value}")
def write(self, new_filename=None):
filename = new_filename or self.filename
with open(filename, 'w', encoding='utf-8') as f:
for key, value in self.properties.items():
if value == '(no parameters)':
f.write(f"{key}\n")
else:
f.write(f'{key}("{value}")\n')
# Example usage:
# handler = MydFileHandler('example.MYD')
# handler.read_and_decode()
# handler.print_properties()
# handler.write('modified.MYD')
This class opens the .MYD file, decodes the text to extract properties, prints them to console, and can write a new file with the extracted properties.
5. Java Class for .MYD File
import java.io.*;
import java.util.*;
import java.util.regex.*;
public class MydFileHandler {
private String filename;
private Map<String, String> properties = new LinkedHashMap<>();
public MydFileHandler(String filename) {
this.filename = filename;
}
public void readAndDecode() throws IOException {
try (BufferedReader reader = new BufferedReader(new FileReader(filename))) {
String line;
while ( (line = reader.readLine()) != null ) {
line = line.trim();
if (!line.isEmpty() && !line.startsWith("//") && !line.startsWith("REM") && !line.startsWith("#") && !line.startsWith("--")) {
Pattern pattern = Pattern.compile("(\\w+)\\s*\\((.*)\\)");
Matcher matcher = pattern.matcher(line);
if (matcher.matches()) {
String key = matcher.group(1);
String value = matcher.group(2).replaceAll("[\"']", "");
properties.put(key, value);
} else if (line.matches("^\\w+$")) {
properties.put(line, "(no parameters)");
}
}
}
}
}
public void printProperties() {
for (Map.Entry<String, String> entry : properties.entrySet()) {
System.out.println(entry.getKey() + ": " + entry.getValue());
}
}
public void write(String newFilename) throws IOException {
String file = newFilename != null ? newFilename : filename;
try (BufferedWriter writer = new BufferedWriter(new FileWriter(file))) {
for (Map.Entry<String, String> entry : properties.entrySet()) {
if (entry.getValue().equals("(no parameters)")) {
writer.write(entry.getKey() + "\n");
} else {
writer.write(entry.getKey() + "(\"" + entry.getValue() + "\")\n");
}
}
}
}
// Example usage:
// public static void main(String[] args) throws IOException {
// MydFileHandler handler = new MydFileHandler("example.MYD");
// handler.readAndDecode();
// handler.printProperties();
// handler.write("modified.MYD");
// }
}
This class opens the .MYD file, decodes the properties, prints them to console, and can write a new file with the properties.
6. JavaScript Class for .MYD File (Node.js)
const fs = require('fs');
class MydFileHandler {
constructor(filename) {
this.filename = filename;
this.properties = {};
}
readAndDecode() {
const text = fs.readFileSync(this.filename, 'utf8');
const lines = text.split('\n');
lines.forEach(line => {
line = line.trim();
if (line && !line.startsWith('//') && !line.startsWith('REM') && !line.startsWith('#') && !line.startsWith('--')) {
const match = line.match(/(\w+)\s*\((.*)\)/);
if (match) {
const key = match[1];
const value = match[2].replace(/["']/g, '');
this.properties[key] = value;
} else if (/^\w+$/.test(line)) {
this.properties[line] = '(no parameters)';
}
}
});
}
printProperties() {
for (const [key, value] of Object.entries(this.properties)) {
console.log(`${key}: ${value}`);
}
}
write(newFilename = this.filename) {
let content = '';
for (const [key, value] of Object.entries(this.properties)) {
if (value === '(no parameters)') {
content += `${key}\n`;
} else {
content += `${key}("${value}")\n`;
}
}
fs.writeFileSync(newFilename, content, 'utf8');
}
}
// Example usage:
// const handler = new MydFileHandler('example.MYD');
// handler.readAndDecode();
// handler.printProperties();
// handler.write('modified.MYD');
This class opens the .MYD file, decodes the properties, prints them to console, and can write a new file with the properties.
7. C Class for .MYD File
Note: C doesn't have built-in "classes" like object-oriented languages, so this is implemented as a struct with functions (similar to a class).
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <regex.h>
typedef struct {
char* filename;
char** keys;
char** values;
int count;
} MydFileHandler;
MydFileHandler* myd_create(const char* filename) {
MydFileHandler* handler = malloc(sizeof(MydFileHandler));
handler->filename = strdup(filename);
handler->keys = NULL;
handler->values = NULL;
handler->count = 0;
return handler;
}
void myd_read_and_decode(MydFileHandler* handler) {
FILE* f = fopen(handler->filename, "r");
if (!f) return;
char line[1024];
regex_t regex;
regcomp(®ex, "(\\w+)\\s*\\((.*)\\)", REG_EXTENDED);
regmatch_t matches[3];
while (fgets(line, sizeof(line), f)) {
char* trimmed = line;
while (*trimmed == ' ') trimmed++;
if (strlen(trimmed) == 0 || trimmed[0] == '/' || strncmp(trimmed, "REM", 3) == 0 || trimmed[0] == '#' || strncmp(trimmed, "--", 2) == 0) continue;
if (regexec(®ex, trimmed, 3, matches, 0) == 0) {
char* key = strndup(trimmed + matches[1].rm_so, matches[1].rm_eo - matches[1].rm_so);
char* value = strndup(trimmed + matches[2].rm_so, matches[2].rm_eo - matches[2].rm_so);
// Remove quotes from value
if (value[0] == '"' || value[0] == '\'') memmove(value, value + 1, strlen(value));
if (value[strlen(value) - 1] == '"' || value[strlen(value) - 1] == '\'') value[strlen(value) - 1] = '\0';
handler->keys = realloc(handler->keys, (handler->count + 1) * sizeof(char*));
handler->values = realloc(handler->values, (handler->count + 1) * sizeof(char*));
handler->keys[handler->count] = key;
handler->values[handler->count] = value;
handler->count++;
} else if (strcspn(trimmed, " \t\n") == strlen(trimmed) && strlen(trimmed) > 0) {
handler->keys = realloc(handler->keys, (handler->count + 1) * sizeof(char*));
handler->values = realloc(handler->values, (handler->count + 1) * sizeof(char*));
handler->keys[handler->count] = strdup(trimmed);
handler->values[handler->count] = strdup("(no parameters)");
handler->count++;
}
}
regfree(®ex);
fclose(f);
}
void myd_print_properties(MydFileHandler* handler) {
for (int i = 0; i < handler->count; i++) {
printf("%s: %s\n", handler->keys[i], handler->values[i]);
}
}
void myd_write(MydFileHandler* handler, const char* new_filename) {
const char* file = new_filename ? new_filename : handler->filename;
FILE* f = fopen(file, "w");
if (!f) return;
for (int i = 0; i < handler->count; i++) {
if (strcmp(handler->values[i], "(no parameters)") == 0) {
fprintf(f, "%s\n", handler->keys[i]);
} else {
fprintf(f, "%s(\"%s\")\n", handler->keys[i], handler->values[i]);
}
}
fclose(f);
}
void myd_destroy(MydFileHandler* handler) {
for (int i = 0; i < handler->count; i++) {
free(handler->keys[i]);
free(handler->values[i]);
}
free(handler->keys);
free(handler->values);
free(handler->filename);
free(handler);
}
// Example usage:
// MydFileHandler* handler = myd_create("example.MYD");
// myd_read_and_decode(handler);
// myd_print_properties(handler);
// myd_write(handler, "modified.MYD");
// myd_destroy(handler);
This "class" opens the .MYD file, decodes the properties, prints them to console, and can write a new file with the properties. Note: Requires regex support (POSIX regex). Compile with -lregex if needed.