The system cannot find the file specified (randomly occurs) -


i have batch file in download files ftp server. before hand creates folder based on date/time. if there no files download program delete file. deletes files 90% (give or take) of time. other times throws error the system cannot find file specified. not sure makes difference or why doesn't work. if makes difference batch script being run on windows server 2012 r2.

ping ##.#.###.# -n 1 -w 1000 set filename=%date:~10,4%-%date:~4,2%-%date:~7,2%_%time:~0,2%-%time:~3,2%  if %errorlevel% equ 1 (     :: create timestamp of failed ping     echo "unable ping. timestamp: %filename%" > "archive-filetransferprod\%filename%.txt" ) else (      :: create folder on server based on current datetime (24 hour)     md %filename%      :: ftp commands     :: logg in ftp     echo user %username%> ftpcmd.dat     echo %password%>> ftpcmd.dat     echo prompt>> ftpcmd.dat      :: copy items server     echo lcd "%filename%">> ftpcmd.dat     echo mget *>> ftpcmd.dat      :: delete files on server     ::echo mdel *>> ftpcmd.dat      :: disconnect , clean connection     echo disconnect>> ftpcmd.dat     echo bye>> ftpcmd.dat     ftp -n -s:ftpcmd.dat %server%     del ftpcmd.dat       set cnt=0     %%a in ("%filename%\*") set /a cnt+=1      echo file name = %filename%     echo count = %cnt%      :: if folder empty delete     if %cnt% equ 0 (     echo file deleted?         rd /s /q "c:\filetransfer\%filename%"     )   ) 

additional info

i have been going through command prompt , found following. code used doesn't assign proper name folder. happens whether code md %filename% or md "%filename%"

enter image description here

change "%filename%"\* "%filename%\*"

also change rd /s /q c:\filetransfer\"%filename%" rd /s /q "c:\filetransfer\%filename%"


Comments

Popular posts from this blog

authentication - Mongodb revoke acccess to connect test database -

r - Update two sets of radiobuttons reactively - shiny -

ios - Realm over CoreData should I use NSFetchedResultController or a Dictionary? -