请求文件夹位置



我试图从用户请求文件夹在他们的系统上,以便批处理文件可以为用户从一个位置移动到另一个位置。

IE: move (Request source folder here) (Request destination folder here)

感谢您的宝贵时间。

有一种方法,使用一个简单的GUI对话框,可以防止输入错误或不存在的目录位置:

@Echo Off & SetLocal EnableExtensions
Set "FileSpec=*.*"
Set "SourceDirectory="
Echo Please choose your source directory.
Call :GetDirectory SourceDirectory
If Not Defined SourceDirectory GoTo :EOF
Set "DestinationDirectory="
Echo Please choose your destination directory.
Call :GetDirectory DestinationDirectory
If Not Defined DestinationDirectory GoTo :EOF
Echo=Move /Y "%SourceDirectory%%FileSpec%" "%DestinationDirectory%"
Pause
GoTo :EOF
:GetDirectory
For /F Delims^=^ EOL^= %%G In ('^"
"%SystemRoot%System32WindowsPowerShellv1.0powershell.exe" -NoProfile
"(New-Object -COM 'Shell.Application').BrowseForFolder(0,'Select your %1.',1,0).Self.Path"
^"') Do Set "%~1=%%~G"
GoTo :EOF

更改要移动的文件的文件规格,(在3线上的="之间)

如果您对输出感到满意,请从15行删除Echo=以实际移动文件,而不是仅显示命令。

包含16行只是为了防止在测试期间脚本可能关闭,您可以删除它,或者根据需要用其他命令替换它。请不要删除18及以下行

最新更新