to_dir should be filtered through doc.normalize_asset_path, which basically enforces the safe-mode setting, as in:

```ruby
doc.normalize_asset_path(to_dir)
```

(it works with both files and directories)