How would I get a batch file to copy from a certain directory that contains a file with a name that would be different every time the batch file is run. Ex.:
如何从某个目录中获取批处理文件进行复制,该目录包含每次运行批处理文件时名称不同的文件。例:
copy "C:\Users\%USER%\AppData\Local\Microsoft\Windows\INetCookies"
%USER%
is the changing file name.
%USER%是更改文件名。
2 个解决方案
#1
2
%username%
is the environment variable for the current user's username. and
是当前用户的用户名的环境变量。和
%userprofile%
is the path to their profile.
是他们的个人资料的路径。
#2
0
In addition to the already provided answer, you can get even further down the path using another of the built-in environment variables, %LOCALAPPDATA%.
除了已经提供的答案之外,您还可以使用另一个内置环境变量%LOCALAPPDATA%进一步沿着路径前进。
"%LocalAppData%\Microsoft\Windows\INetCookies"
Type SET followed by [Enter] into a cmd.exe window to see all of the machine's variables listed.
在“cmd.exe”窗口中键入SET,然后按[Enter]键以查看列出的所有计算机变量。
#1
2
%username%
is the environment variable for the current user's username. and
是当前用户的用户名的环境变量。和
%userprofile%
is the path to their profile.
是他们的个人资料的路径。
#2
0
In addition to the already provided answer, you can get even further down the path using another of the built-in environment variables, %LOCALAPPDATA%.
除了已经提供的答案之外,您还可以使用另一个内置环境变量%LOCALAPPDATA%进一步沿着路径前进。
"%LocalAppData%\Microsoft\Windows\INetCookies"
Type SET followed by [Enter] into a cmd.exe window to see all of the machine's variables listed.
在“cmd.exe”窗口中键入SET,然后按[Enter]键以查看列出的所有计算机变量。