(Command Line Utilities)
The scripts are provided as source with comments, not compiled, minified, or otherwise obfuscated. The code is easy to understand and translate to PHP, C#, or other languages if desired. I would have already, but my goal was to test drive Node.js and see what it could do. You may use these scripts as-is, translate/modify for your own situation, or pick up ideas for other solutions. Download and enjoy. Feel free to contact me with questions or conversation.
The scripts on this page require that Node.js is installed on the platform that will launch the script. Visit nodejs.org to download.
Delete Mac Junk
Removes excess Mac 'dot bar' files (prefixed by dot and underscore, containing Mac resource fork). Useful for Windows and Linux file servers to which Mac clients connect over SMB. Unlike simple scripts designed to accomplish the same by deleting resource fork files based on file extension, this script inspects the contents of the file to determine if it is truly excess. Only when the text 'This resource fork intentionally left blank' is discovered will the file be deleted. One benefit is that resource forks belonging to folders are also detected and deleted. The script also deletes '.DS_Store' and '._.DS_Store' files, and ignores Windows directories '$RECYCLE.BIN', 'System Volume Information', and 'TemporaryItems'. Search is recursive (all subfolders included by default). A log file is created in the directory from which script is launched. Optional argument '-prunelog' clears log entries older than a specified number of days. If omitted or the value is zero, the log is not pruned.
Usage: node delete-mac-junk.js -dir <directory> [-prunelog <days old>]
node delete-mac-junk.js -dir E:\jobs -prunelog 90
Adjust directory syntax as needed for flavors of *nix other than macOS. Use on a Mac server would not make sense — the purpose is to clear away junk that non-Mac servers view as clutter.
For automation, add the command to a batch file triggered by Windows Task Scheduler (or Crontab file on Linux).
Delete Mac Junk
Removes orphaned files from SageTV recording directories. Leftover files from plug-ins like Comskip can be annoying. Annoys me anyway. There are other means to clear out leftover files, but I wanted total automation.
The script searches the specified directory and compiles a list of all video files (extensions mpg|mp4|avi|ts|mkv|m4v), and a list of all non-video files. For each non-video file, the script tests if a matching video files exists. If not, the non-video file is deleted.
Also, for any .properties file found, if a matching video file exists but has a different extension, the .properties file is renamed to match. This condition can exist when metadata is downloaded and a .properties file created prior to completion of auto-conversion of the video file (if auto-conversion is enabled for the particular favorite).
A log file is created in the directory from which script is launched. Optional argument '-prunelog' clears log entries older than a specified number of days. If omitted or the value is zero, the log is not pruned.
Usage: node clean-sagetv.js -dir <directory> [-prunelog <days old>]
node clean-sagetv.js -dir E:\Recorded_TV -prunelog 90
Adjust directory syntax as needed for flavors of *nix.
For automation, add the command to a batch file triggered by Windows Task Scheduler (or Crontab file on Linux). For multiple recording directories, repeat the command as needed with the desired -dir argument.
Scripts on this page are free to download and use. Contributions of any amount are appreciated but not required.
Also available for hire to program custom solutions. Contact William for more information.
IMPORTANT: by downloading any of the scripts on this site you agree that the software is provided without any warranty, express or implied. USE AT YOUR OWN RISK. Always make backups of important data.