从主OS驱动器以外的任何其他驱动器调用文件时,批处理文件中断

时间:2016-12-12 22:56:58

标签: batch-file directory

第一篇帖子很温柔。我有一个我创建的批处理文件,它基本上将任何图像或pdf拖到它上面,通过转换程序运行它(取决于文件扩展名),重命名它,然后运行我们的自定义上传程序将它加载到我们的系统中。

这似乎适用于从主操作系统硬盘驱动器拖动的任何文件,但是当从任何其他驱动器(本地驱动器或映射的网络驱动器等)拖动时,它会中断并给出错误说“系统无法找到指定的文件“

我需要做些什么调整?

提前感谢您的帮助!

@echo off

set libpath=%~p0

set filename=%1
set fileext=%~x1

IF /I %fileext%==.jpg GOTO ConvertIMAGE
IF /I %fileext%==.eps GOTO ConvertIMAGE
IF /I %fileext%==.psd GOTO ConvertIMAGE
IF /I %fileext%==.png GOTO ConvertIMAGE
IF /I %fileext%==.gif GOTO ConvertIMAGE
IF /I %fileext%==.tif GOTO ConvertIMAGE
IF /I %fileext%==.bmp GOTO ConvertIMAGE
IF /I %fileext%==.tiff GOTO ConvertIMAGE
IF /I %fileext%==.jpeg GOTO ConvertIMAGE
IF /I %fileext%==.pdf GOTO ConvertPDF
GOTO ErrorMessage

:ConvertIMAGE
"C:\Program Files (x86)\TotalImageConverter\ImageConverter.exe" "%filename%" "%cd%" -s1800x1800 -o ue -c tif ext tif tc auto log c:\TIFFlog.txt -verbosity detail 
call set filename=%%filename:%fileext%=.tif%%
Goto UploadImage

:ConvertPDF
"C:\Program Files (x86)\CoolUtils\Total PDF Converter\PDFConverter.exe" "%filename%" "%cd%" -c tif ext tif tc JPEG 
call set filename=%%filename:%fileext%=.tif%%
Goto UploadImage

:ErrorMessage
echo Not A Valid File Type
Pause

GOTO SkipUpload

:UploadImage

set d=%date:~-4,4%%date:~-10,2%%date:~-7,2%
set d=%d: =_%
set t=%time:~0,2%%time:~3,2%%time:~6,2%
set t=%t: =0%
set stampedfilename=hXXXXXX.%d%-%t%___C7451F.tif
rename %filename% %stampedfilename%

call "%libpath%nametif.bat" %stampedfilename%

chdir C:\KLS\Uploader

call upload.bat

:SkipUpload

编辑:添加其他名为批处理文件

这是nametif.bat

@echo off
SETLOCAL ENABLEDELAYEDEXPANSION

set tifpath=C:\KLS\hardcopy\

set libpath=%~p0

REM set filename=HXXXXXX.20110111-152930___ACA51F.TIF
set filename=%~n1%~x1
set fileext=%~x1
set filepath=%~p1
echo.%filename%

start /w wscript.exe "%libpath%inputhawb.vbs"
call "%libpath%~userin.bat"
del "%libpath%~userin.bat"
set hawb=%USERIN%
REM set hawb=1234567
echo.%hawb%

set filename=%filename:~0,-13%
set filename=%filename:XXXXXX=!hawb!%%fileext%
set filename=%filename:H=h%
set filename=%filename:TIF=tif%
echo.%filename%

rename %1 %filename%
move "%filepath%%filename%" "%tifpath%"
echo %tifpath%

这是nametif.bat调用的inputhawb.vbs文件

strUserIn = InputBox("Enter Hawb") 
Set fs = CreateObject("Scripting.FileSystemObject") 
strFileName = fs.BuildPath(Wscript.ScriptFullName & "\..", "~userin.bat") 
strFileName = fs.GetAbsolutePathName(strFileName) 
Set ts = fs.OpenTextFile(strFileName, 2, True) 
ts.WriteLine "set userin=" & strUserIn 
ts.Close

upload.bat文件只是对使用java的.jar上传平台的非常通用的调用。

感谢所有帮助的人!

0 个答案:

没有答案