@echo off rem -- Create a ZIP file containing a snapshot of a simulator subdirectory. rem -- The file is stored in the indicated subdirectory. rem -- rem -- Invocation: rem -- rem -- snap rem -- rem -- Notes: rem -- rem -- 1. In order to allow specification of the subdirectory in lower case rem -- but create the ZIP file using the actual (upper) case, we employ rem -- the FOR /D command to match the actual directory name. rem -- rem -- 2. We employ the GNUWin32 utility "date.exe" to generate the current rem -- date in ISO (e.g., 2018-02-22) format. Because "date" is an rem -- internal command, we must use the "start" command (to avoid having rem -- to specify the absolute path) and specify the ".exe" extension in rem -- order to get the utility to run, and we have to use the FOR /F rem -- command to get the result into a substitution variable (the obvious rem -- alternative of piping the result into a SET /P command does not rem -- work -- the variable never receives the value). rem -- rem -- 3. Because the target subdirectory is two levels down, i.e., below the rem -- SCP subdirectory, we must execute the ZIP command within the SCP rem -- subdirectory so that the resulting archive contains only the "doc" rem -- and target directories. Executing from the current directory would rem -- store everything under SCP\. The --junk-paths rem -- command cannot be used, as it strips all subdirectories, whereas we rem -- only want to strip one (the SCP subdirectory). if not "%1" == "" if exist SCP\%1\nul goto :ok :usage echo. echo Must specify the subdirectory to use for the snapshot. goto :end :ok for /D %%i in (SCP\%1*) do pushd SCP & for /F %%d in ('start /b /wait date.exe --iso-8601') do zip -R %1\%%~ni-%%d.zip %1_doc.doc %1\*.c %1\*.h %1\*.txt & popd echo. :end