I am using GitHub Desktop on Windows and am trying to create a batch file that will execute every hour to auto commit and push. I also want it to add all files in the repository and exclude those bigger than 99Mb in the .gitignore file.
Here is what i managed to do till now:
cd C:\Users\XXX\Desktop\myRepo
forfiles /s /c "cmd /q /c if @fsize GTR 12976128 echo @relpath" >> .gitignore
git add --all
git commit -m "autoCommit %date:~-4%%date:~3,2%%date:~0,2%.%time:~0,2%%time:~3,2%%time:~6,2%"
git push
exit
The problem is, the written path to the big files have to be manipulated to look like this:
".\myFile.mkv" (Wrong)
myFile.mkv (Right)
Or
".\myFolder\myFile.mkv"
myFolder/myFile.mkv
So i tried to manipulate it with this example code:
set str=".\myFolder\myFile.mkv"
set str=%str:~3,-1%
set str=%str:\=/%
echo.%str%
Which delivers myFolder/myFile.mkv
So i implemented this code in the original one:
cd C:\Users\XXX\Desktop\myRepo
forfiles /s /c "cmd /q /c if @fsize GTR 12976128 set str=@relpath set str=%str:~3,-1% set str=%str:\=/% echo.%str%" >> .gitignore
git add --all
git commit -m "autoCommit %date:~-4%%date:~3,2%%date:~0,2%.%time:~0,2%%time:~3,2%%time:~6,2%"
git push
exit
But it doesn't work. I'm not good with Batch scripting so maybe someone knows how to make this work?