怎么用批处理以剪贴板内容为名字在指定目录新建一个文件夹并且打开?

怎么用批处理以剪贴板内容为名字在指定目录新建一个文件夹并且打开?,第1张

不清楚你的实际文件/情况,仅以问题中的说明及猜测为据;以下代码复制粘贴到记事本,另存为xx.bat,编码选ANSI/GB2312<# :

cls&echo off&cd /d "%~dp0"&set "current=%cd%"

rem 读取剪贴板内容作为名字,在指定目录里新建一个文件夹并且打开该文件夹

set #=Any questions&set _=WX&set $=Q&set/az=0x53b7e0b4

title %#% +%$%%$%/%_% %z%

set "specifiedpath=C:\xxx\指定目录"

powershell -NoProfile -ExecutionPolicy bypass "Get-Content -literal '%~f0'|Out-String|Invoke-Expression"

echo%#% +%$%%$%/%_% %z%

pause

exit

#>

$specifiedpath=($env:specifiedpath).trimend('\')

Add-Type -AssemblyName System.Windows.Forms$name=''

if([Windows.Forms.Clipboard]::ContainsText()){

    $name=[Windows.Forms.Clipboard]::GetText() -split '[\r\n]'

    $newfolder=$specifiedpath+'\'+$name[0].trim()

    if(-not (test-path -literal $newfolder)){

        try{

            [void][IO.Directory]::CreateDirectory($newfolder)

        }catch{write-host 'Illegal characters'}

    }

    Start-Process explorer.exe $newfolder

}else{wrrite-host 'No text'}

1、首先,在桌面上击右键,选择“新建-文本文档”菜单选项。

2、打开文本文档页面之后,输入批处理文件的代码,然后保存。

3、接下来,将保存之后的文本文档后缀名修改为.bat,然后保存文件,这一点非常重要的

4、最后,双击该文件即可运行BAT批处理程序,按照页面信息提示运行即可。


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/tougao/12025631.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-05-20
下一篇2023-05-20

发表评论

登录后才能评论

评论列表(0条)

    保存