Solved Urgent help with batch scripting required

November 23, 2015 at 16:01:39
Specs: Windows 64

I've a batch script that I got given to further optimize and plug into our automation framework. I've been able to port it to the automation framework and the scripting in itself works fine. But it fails when a .suo file pre-exists. I've been trying to sneak in an additional check to see if the .suo file pre-exists and delete if so. But it's not working at the /.git/ folder is hidden. I'm obviously missing an attribute perhaps, if any of you could help review the script, that would be great. Thanks in advance:

CALL git --version
cd "%WORKSPACE%\..\..\..\"
FOR /F "tokens=*" %%N IN ('git rev-parse --show-toplevel') DO SET git_path=%%N
SET git_path=%git_path:/=\%
IF NOT "%git_path%" EQU "%CD%" exit 1
rem check for fixit file
del /S /F /AH .git\*.suo
CALL git add -Av .
SET /A staged_changes=0
FOR /F "tokens=*" %%N IN ('git status --porcelain') DO SET /A staged_changes=staged_changes+1
IF %staged_changes% EQU 0 exit 0
CALL git commit --author=tst_usr --quiet --untracked-files=no --message=backup
CALL git whatchanged --no-abbrev -M --pretty=raw HEAD~1..HEAD>"%WORKSPACE%\..\builds\%BUILD_ID%\log.xml"
CALL git push origin master
CALL git tag %tag%
CALL git push origin tag %tag%

message edited by karthikd

See More: Urgent help with batch scripting required

Report •

November 23, 2015 at 17:24:08
del /S /F /AH .\git\*.suo
Remove the first backslash.

How To Ask Questions The Smart Way

Report •

November 23, 2015 at 17:59:41
Hi Razor, thanks for your help. That's my bad. I have actually got it correct in my script. So it looks like this:
del /S /F /AH .git\*.suo

When it executes, because the .git folder is hidden, I think the execution framework can't see it and it throws the following error:

Could Not Find C:\Program Files\DAF\.git\*.suo
fatal: Unable to create 'C:/Program Files/DAF/.git/fixit.suo': File exists.

Report •

November 23, 2015 at 20:53:09
✔ Best Answer
I think it might be another problem altogether. I ran simple test with a -H hidden directory ".git" with a few .suo files in it, and a simple 'del .gif\*.suo' worked fine. Put a "pause" after the simple "cd" line in your code, check that you are in the correct directory. I think it may be a path problem with all that stuff before the "kill switch".

Report •

Related Solutions

November 23, 2015 at 21:18:58
Spot on nbrane! that worked. It was a bit of an overkill / oversight. Removing the /AH worked because it's the .git folder which is hidden, not the *.suo files. Since they are not hidden, the kill switch didn't work. Thanks for your help.

Report •

Ask Question