Agito obviam astrum
Ye, or....just erases the file!
No, it doesn't erases that file, it just refreshes the date.
I just tried this command from the cmd line in Windows XP and it erased the file. The following command is working:copy /b test.txt +,,
For me, the file size becomes 0. Anyway, the other command works fine.
When you copy NULL to a file, the file is still there, but it's now empty. The file is not much use after that.
The original command is updated; it's ok now.
Thanks for the update, newbies still need to work hard to get it done right ;)
Thanks - I took it and made a wrapper, mytouch.cmd, which is in a folder in my PATH env var. If using on files with embedded spaces, just enclose the filename in quotes on the command line, it seems to work nicely:mytouch.cmd:@echo offset arg1=%*%arg1%copy /b %arg1% +,,SAMPLE USAGE:mytouch "some old file.txt"It simply results as you have indicated, in the file's datestamp being updated to current datetime.COOL. Thanks again for the simple syntax for the copy with "/b" flag.
thanks. it's working.. But, how to make it to run for the whole folder?? Any idea?
@echo offrem Creates empty filesif not '%1'=='' goto loop echo Usage: touch file... echo creates empty files goto done:loop type nul >> %1 shift if not '%1'=='' goto loop:done////////Put the above code into a batch script. Place it in a file area for personal batch scripts. Call that file touch. Make sure the file area is on the system PATH or the local user PATH variable. Then you can use the command to make blank files.
Interesting... I used mytouch.cmd on a PowerPoint document, and it opened the file. Of course, when I closed it, the timestamp had changed. (The simple copy command worked with no such interesting behavior.)
Hey Read it before you use it!What do you guess will %arg1% do?Be happy it was not makeClean.bat you where using it. I think the idea of a wrapper is OK but:why not just copy %* +,,The main trick is the "+,," thing, thanks for that!
Gary's script works if there is no BLANK in the filename, maybe he can improve it so it accepts BLANKS in the filename
Good One! Thanks!
Post a Comment