Last active
July 3, 2019 07:16
-
-
Save anzeljg/d916d10ff0ad035822b0118a60a93d1f to your computer and use it in GitHub Desktop.
implementation of 'touch' command on Windows
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Windows does not natively include a touch command. | |
You can use any of the available public versions or you can use your own version. | |
Save this code as touch.cmd and place it somewhere in your path. | |
@echo off | |
setlocal enableextensions disabledelayedexpansion | |
(for %%a in (%*) do if exist "%%~a" ( | |
pushd "%%~dpa" && ( copy /b "%%~nxa"+,, & popd ) | |
) else ( | |
type nul > "%%~fa" | |
)) >nul 2>&1 | |
It will iterate over it argument list, and for each element if it exists, update the file timestamp, else, create it. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment