Create batch file that sees whether file exists and if not exits

if exist "%BackupPath%\%programName%\*_%date:~4,2%%date:~7,2%%date:~12,2%.zip" (
if not exist "%BackupPath%\%programName%\*_%date:~4,2%%date:~7,2%%date:~12,2%.zip" (
echo x=messagebox(zip file with latest date not avaialble)
) else (
goto :EOF
)
)

what will be the issue in the code??

poup up echo message not coming prperly.
sasi vAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

KimputerCommented:
Is this partial code of the batch file, or FULL code?

If FULL, you're obviously missing all the variables.
2
NVITEnd-user supportCommented:
This works.
Adjust BackupPath and programName to your needs.
I moved the filename date pattern to a variable FName to ease maintenance.

@echo off
setlocal enabledelayedexpansion

set BackupPath=C:\local\test
set programName=EE
set FName=*_%date:~4,2%%date:~7,2%%date:~12,2%.zip

if exist "%BackupPath%\%programName%\%FName%" (
	echo It's here! %fname%
) else (
	echo x=messagebox(zip file with latest date not avaialble)
	goto :EOF
)

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Ben Personick (Previously QCubed)Lead Network EngineerCommented:
I suspect this is pseudo-code we've all been dealing with in several open Qs by Bhavani V.

If he could be more forthcoming in answering Qs and keeping scope creep to a minimum it would be helpful.

Hell is he would listen to the repeated attempts people have made to get him to use [ code ] [ /code ] tags it would be helpful.

I mean this code obviously seems to be Pseudo-code:

messagebox(zip file with latest date not available)

Open in new window


I'm guessing he's thinking of "Net SEND" which is no longer functional.

the functionality could be duplicated to some extent a number of ways.

I prefer using straight CMD so something like this:

START "Zip file with latest date not available" /WAIT "cmd /K MODE CON COLS=45 LINES=10&CLS&ECHO.&ECHO.&ECHO.============================================&ECHO.  Zip file with latest date not available!&ECHO.&PAUSE&exit /b"

Open in new window


However, it could be done using Powershell calls or VBScript too.

We need Bhavani V. to work with us to properly scope and break apart his needs into a set of Qs designed to help him understand and create his total script, OR he needs to work with us to create the entire thing end to end in one go as a Gig (or, I guess, a single all-encompassing question, since Gigs went bye bye :(  RIP Gigs :( )
0
Become a CompTIA Certified Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

Ben Personick (Previously QCubed)Lead Network EngineerCommented:
Although, having been on some of his other Qs I'm fairly sure this will do the needful:

@(
	SETLOCAL ENABLEDELAYEDEXPANSION
	ECHO OFF
	SET "_eLvl=0"
	SET "_BackupPath=C:\Your\Path"
	CALL :GetDate
	SET "_FileGlob=*_!_YearMonthDay!.zip"
	SET "_FullGlob=!_BackupPath!\!_FileGlob!"
)

CALL :Main

(
	ENDLOCAL
	EXIT /B %_eLvl%
)

:Main
	IF NOT EXIST "%_FullGlob%" (
		ECHO.File Not Found!  Exiting Once pop-up is cleared...
		START "Zip file with latest date not available" /WAIT "cmd /K MODE CON COLS=45 LINES=10&CLS&ECHO.&ECHO.&ECHO.============================================&ECHO.  Zip file with latest date not available!&ECHO.&PAUSE&exit /b"
		SET "_eLvl=1"
		GOTO :EOF
	) 

	ECHO.  Your code continues here.

GOTO :EOF

:GetDate
	FOR /F "Tokens=1-3 delims=MTWFSmtwfsouehrandit:-\/. " %%A IN ("%DATE%") DO (
		FOR /F "Tokens=2-4 Skip=1 Delims=(-)" %%a IN ('ECHO.^| DATE') DO (
			SET "%%~a=%%~A"
			SET "%%~b=%%~B"
			SET "%%~c=%%~C"
			SET /a "#%%~a=1%%~A - (2%%~A-1%%~A)"
			SET /a "#%%~b=1%%~B - (2%%~B-1%%~B)"
			SET /a "#%%~c=1%%~C - (2%%~C-1%%~C)"
		)
	)
	SET "_YearMonthDay=%yy%%mm%%dd%"
GOTO :EOF

Open in new window

0
sasi vAuthor Commented:
how to check the files are available in the folder or not?

i used *.* but its not working. files are not at all available but the remaining process are continuing.
 any other options are ter to check it?


  setlocal EnableDelayedExpansion & time /T
  Date /T
 
  IF EXIST "%ProgramPath%\%programName%\%dateFile%\*.*" (
  ECHO "LATEST FOLDER IS CREATED ..........PROCESS IS STARTED......."
  GOTO :1
  ) ELSE (
  ECHO "LATEST FOLDER NOT CREATED.... CREATE FOLDER AND START PROCESSING!!"
  PAUSE
  EXIT /B
  )
:1
Mkdir "%BackupPath%\%programName%\%date:~4,2%%date:~7,2%%date:~12,2%"
for /d %%A in ("%ProgramPath%\%programName%\%dateFile%\*.*") do (
    copy "%%~A\*.zip" "%BackupPath%\%programName%\%dateFile%"
      )
0
Ben Personick (Previously QCubed)Lead Network EngineerCommented:
Bhavi,

  It would behoove you to read the responses and reply to them instead of continually posting additional questions.

 I know you have been repeatedly told to use [ code ]  [/code ] tags and the like, and giving may questions which are not answered by you.

 I suspect you are not a native English speaker, perhaps you can tell us what your native language is?

If you explain this, then perhaps we can find another expert who might be kind enough to assist us in translating these messages between us.

What is your native language?

Ben
0
sasi vAuthor Commented:
hi,

i got it what you guys are saying to attach the code file. i tried i dont know its correct or not. now i attaching check it out. native language is Tamil but i can understand English as well sir.

how to check the files are available in the folder ? i used *.* but its not working.
actually my  files are not available inside the folder but its processing remaining process as well. kindly help me to check the files in code
attached.txt
0
KimputerCommented:
Seems you didn't read a lot of the messages again.
Even the first message you missed. I already told you, you were missing variables. Then the next message is about how you should fill in the variables. And then, you just ignored it.
If you ignore all or some messages, you will get nowhere.
1
sasi vAuthor Commented:
Oops sorry again.. i attached the code again. now its possible to check  my question?
attached.txt
0
KimputerCommented:
Remove all "echo off" in the code, run again, show us output.
That's because batch file dates depends on system display settings, which is different on every system (could be d/M/y or mm-dd-yyyy whichever is preferred by the user, thereby sometimes creating a folder with / as a character)
Changing it to VBscript would be nicer (and make the script more readable).
0
sasi vAuthor Commented:
office system settings date only i used in the code. so no issue in that. sorry i need in .bat file for office purpose.
0
KimputerCommented:
You just started NOT READING AND LISTENING again. I told you before you will get nowhere if you do that.
I need the OUTPUT, as the DATE SETTINGS of YOUR PC or SERVER AFFECTS THE BATCH FILE OUTPUT and actually CAN'T CREATE FOLDERS if a "/" character is used.
1
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
batfile

From novice to tech pro — start learning today.