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