Skip to content
This repository
Browse code

Added Rename & Save destination

  • Loading branch information...
commit af2ed0bb07e81a451dc578bd2fa28eddc7808c14 1 parent ca4c3db
aptonic authored

Showing 1 changed file with 39 additions and 0 deletions. Show diff stats Hide diff stats

  1. +39 0 Rename & Save.dropzone
39 Rename & Save.dropzone
... ... @@ -0,0 +1,39 @@
  1 +#!/usr/bin/ruby
  2 +# Dropzone Destination Info
  3 +# Name: Rename & Save to Folder
  4 +# Description: Allows you to rename files and save them to a folder of your choice.
  5 +# Handles: NSFilenamesPboardType
  6 +# Creator: Buster P. Keaton
  7 +# URL: http://www.notarealURI.com
  8 +# OptionsNIB: ChooseFolder
  9 +
  10 +def dragged
  11 + output = `./CocoaDialog standard-inputbox --title "Rename File" --e --informative-text "Enter new name for this file (minus extension):"`
  12 + filename = output.split("\n")[1]
  13 +
  14 + if filename == ""
  15 + $dz.finish("Empty Filename")
  16 + $dz.url(false)
  17 + return
  18 + end
  19 +
  20 + $dz.determinate(false)
  21 + $dz.begin("Copying file...")
  22 +
  23 + ext = File.extname($items[0]).downcase[1..-1]
  24 + new_filepath = ENV['EXTRA_PATH'] + "/" + filename + "." + ext
  25 + result = `cp \"#{$items[0]}\" \"#{new_filepath}\" 2>&1`
  26 +
  27 + if result == ""
  28 + $dz.finish("Copy Complete")
  29 + $dz.url(false)
  30 + else
  31 + $dz.finish("Copy Failed")
  32 + $dz.url(false)
  33 + end
  34 +end
  35 +
  36 +def clicked
  37 + escaped_path = ENV['EXTRA_PATH'].gsub(/["`$\\]/){ |s| '\\' + s }
  38 + system("open \"#{escaped_path}\"")
  39 +end

0 comments on commit af2ed0b

Please sign in to comment.
Something went wrong with that request. Please try again.