Can anyone explain me how to do this?
Problem is @fname
contains quotes so concatting %source%
and @fname
gives an error...
forfiles /P "%source%" /M %file%.* /D -1 /C "cmd /c if exists %source%\@fname.pdf del @path"
Can anyone explain me how to do this?
Problem is @fname
contains quotes so concatting %source%
and @fname
gives an error...
forfiles /P "%source%" /M %file%.* /D -1 /C "cmd /c if exists %source%\@fname.pdf del @path"
The double quotes are not the issue. You've got a syntax error in your command line: instead of if exists …
it should go if exist …
.
For anyone interested this is the full script.
@echo off
set ERRORLEVEL=0
::variables
set source=C:\ASWFORM\argus
set ps2pdf=C:\Progra~1\gs\gs9.07\gs\lib\ps2pdf
::parameters
if [%1]==[] goto hell
if [%2]==[] goto hell
set file=%1
set hotfolder=%2
:: *********************************************************************************************
::delete files from yesterday
forfiles /P "%source%" /M %file%.* /D -1 /C "cmd /c if exist %source%\@fname.pdf del @path"
::create pdf files
forfiles /P "%source%" /M %file%.ps /C "cmd /c call %ps2pdf% @path"
::move files to hotfolder
xcopy /Y /V %source%\%file%.pdf %hotfolder%
xcopy /Y /V %source%\%file%.xml %hotfolder%
xcopy /Y /V %source%\%file%.adj %hotfolder%
forfiles /P "%source%" /M %file%.* /C "cmd /c if exist %source%\@fname.pdf del @fname.ps"
goto heaven
:hell
echo Usage argus.bat [filename without extension] [path to archive hotfolder]
:heaven
exit 0
:: *********************************************************************************************