예제 #1
0
    public static int Main (string [] args)
    {
        var script = new FileScript (args, (file) => {
            var tryCount = 2;
            var result = 0;

            while (tryCount > 0) {
                // run unoconv
                result = Command.Run ("unoconv", string.Format ("-f pdf \"{0}\"", file));
                if (result == 0) {
                    FileHelper.Backup (file, "~backup", BackupType.Numbered);
                    File.Delete (file);
                    break;
                }
                tryCount--;
            }

            if (result != 0) {
                throw new Exception (string.Format ("Cannot convert \"{0}\" file.", file));
            }

            return result;
        });

        // TODO: Filter by extension (list may be very large)
        script.Files = FileHelper.GetFiles (FileSource.Nautilus);

        var scriptResult = script.Run ();
        return scriptResult;
    }
    public static int Main (string [] args)
    {
        var maxSize = 1024;

        var script = new FileScript (args, (file) => {
            FileHelper.Backup (file, "~backup", BackupType.Numbered);
            return Command.Run ("convert", string.Format (
                "\"{0}\" -auto-orient -interpolate filter -filter lanczos " +
                "-resize {2}x{2}> -quality 92 -sampling-factor 1:1:1 " +
                "-interlace Line +repage \"{1}\"", file, file, maxSize)
            );
        });

        script.Files = FileHelper.GetFiles (FileSource.Nautilus);
        script.AllowedExtensions.Add (".jpg");
        script.AllowedExtensions.Add (".jpeg");

        var result = script.Run ();        

        return result;
    }