Actually i need write one batch script, in that first i need to check if the required client spec already exist or not? If exist then i should delete it.
Could you please let us know how can we check in a script, if the required client spec exist or not?
On Windows command line you can do something like this
set P4CLIENT=client-name
p4 clients -e %P4CLIENT% | findstr %P4CLIENT% >nul
p4 clients -e %P4CLIENT%
will output all clients matching %P4CLIENT%
. findstr
will search the output of p4 clients
for the client name and print it. The redirection to to nul
will supress this output, but findstr
will additionally set the %errorlevel%
variable.
Some examples:
p4 clients -e existing-client | findstr existing-client >nul
echo %errorlevel%
Will return 0.
p4 clients -e does-not-exists | findstr does-not-exists >nul
echo %errorlevel%
Will return 1.
If you want to execute something, if a given client space does not exists, you can run this command:
p4 clients -e does-not-exists | findstr does-not-exists >nul || create-client.bat
If you want to execute something, if a given client space does exists, you can run this command:
p4 clients -e does-not-exists | findstr does-not-exists >nul && do-something.bat
Thanks to Adam from the perforce online chat support!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With