omn*_*nix 21 windows cmd batch-file
我试图在用户创建文件后在其默认编辑器中打开文件.到目前为止,我的脚本是:
@echo off
@echo --- Create A New File ---
@echo -
@echo Where should we put the new file?
set /p fileLocation=@ %UserProfile%\
@echo -
@echo What do you want to call your new file?
set /p fileName=@
@echo -
@echo Almost Done! What is the files extension?
set /p extension=@ .
@echo -
copy NUL "%UserProfile%\%fileLocation%\%fileName%.%extension%"
Run Code Online (Sandbox Code Playgroud)
(忽略额外的回声和'@'那些只是为了好玩)
单击该文件后,它执行以下命令:Choose Location > Choose File Name > Choose File extension.我几乎完成了我想要的东西,但最后还有一件事.如何获取我创建的文件名,然后在其默认文本编辑器中打开?
Oli*_*ver 11
在Windows中,您可以使用start(http://ss64.com/nt/start.html).
start "" "%UserProfile%\%fileLocation%\%fileName%.%extension%"
Run Code Online (Sandbox Code Playgroud)
您还可以使用explorer.exe/explorer打开文件(例如explorer file.txt)。如果您使用 WSL,这也能很好地工作,尤其是使用像alias open="explorer.exe"这样的别名,这样您就可以像这样称呼它,例如open file.txt.
| 归档时间: |
|
| 查看次数: |
22266 次 |
| 最近记录: |