[英]Save just changed directory to file
How could you save the freshly changed directory to a file? 你如何将刚刚更改的目录保存到文件中? I thought this would work, but it executes the commands in the same directory:
我认为这会工作,但它执行相同目录中的命令:
cd desired_dir && echo foo && echo %CD% > path.txt
Is there an operator like "do this. after finishing, do this with the new parameters" in cmd? 是否有像“执行此操作的操作员。完成后,在cmd中使用新参数执行此操作”?
I use this command to get the directory for a web-based commandline (using php). 我使用此命令获取基于Web的命令行的目录(使用php)。 I read the current path from a file, execute some code and save the new path into a file.
我从文件中读取当前路径,执行一些代码并将新路径保存到文件中。
The echo %CD%
will "lock in" the %CD%
value that exists at the time the command is parsed. echo %CD%
将“锁定”解析命令时存在的%CD%
值。 If you want the "real time" directory, use this: 如果您想要“实时”目录,请使用以下命令:
cd desired_dir && echo foo && cd > path.txt
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.