View Single Post
Old 10-11-2010, 11:01 AM   #98
badbob001
Evangelist
badbob001 ought to be getting tired of karma fortunes by now.badbob001 ought to be getting tired of karma fortunes by now.badbob001 ought to be getting tired of karma fortunes by now.badbob001 ought to be getting tired of karma fortunes by now.badbob001 ought to be getting tired of karma fortunes by now.badbob001 ought to be getting tired of karma fortunes by now.badbob001 ought to be getting tired of karma fortunes by now.badbob001 ought to be getting tired of karma fortunes by now.badbob001 ought to be getting tired of karma fortunes by now.badbob001 ought to be getting tired of karma fortunes by now.badbob001 ought to be getting tired of karma fortunes by now.
 
badbob001's Avatar
 
Posts: 447
Karma: 1042602
Join Date: Sep 2009
Device: Kindle 3 (US 3G)
Here is an update of my drag-drop script for canti.
  • Better error handling when nothing is dropped onto the script.
  • Better support for paths and files names with non-alphanumeric characters like &.
  • Can support UNC paths (eg: \\server\share) for input and canti itself.
  • If canti.properties does not exist, will guide the user to create it.

It looks like if canti.jar is on a unc path, canti ignores the canti.properties file in the same location but looks for it in the user's profile folder. This applies as well when canti creates the properties files. I've resolved this by forcing canti to look in its current location with the -properties parameter.

Code:
@echo off
echo Script start...
set jar=canti.jar
set prop=canti.properties

if !%1!==!! goto:usage

set parent_folder=%1
set title="%~n1"
set current_folder="%~dp0"
set jar="%~dp0%jar%"
set prop="%~dp0%prop%"
set output_folder="%~dp0%~n1\"

set parent_folder=%parent_folder:\=\\%
set output_folder=%output_folder:\=\\%

:prop_check
if exist %prop% goto:prop_ok
echo - Setup ----------------
echo * Canti.Properties file does not exist. Please type in the device you have from the following list:
echo default, kdx, k2, ipad, nook, prs-900, prs-700, prs-600, prs-505, prs-500, prs-300, iliad, dr800, dr1000, jb, jbl
echo.
:prop_setup
set /p device=Your Device:
if !%device%!==!! goto:prop_setup
java -jar %jar% -create_properties %device%
if exist "%userprofile%\canti.properties" move /y "%userprofile%\canti.properties" %current_folder%
goto:prop_check

:prop_ok
set prop=%prop:\=\\%
echo - Parameters ----------------
echo * jar=%jar%
echo * prop=%prop%
echo * parent_folder=%parent_folder%
echo * title=%title%
echo * output_folder=%output_folder%
echo.
echo - To Run ----------------
set to_run=java -jar %jar% -properties %prop% -parent_folder %parent_folder% -title %title% -output_folder %output_folder%
echo %to_run%
echo.
pause
%to_run%
goto:end

:usage
echo * Usage: Drag folder or archive onto script.
goto:end

:end
echo ...Script end.
pause

Last edited by badbob001; 10-11-2010 at 03:25 PM. Reason: Removed quotes causing canti.properties to not be found.
badbob001 is offline   Reply With Quote