标题: [已解决] 20元求助:批处理改进方案给拖入文件夹挂上图标 [打印本页]
作者: sykIII 时间: 2019-11-6 17:57 标题: [已解决] 20元求助:批处理改进方案给拖入文件夹挂上图标
本帖最后由 sykIII 于 2019-11-7 23:20 编辑
- setlocal enabledelayedexpansion
- >"%tmp%\t.t" echo;!cmdcmdline!
- endlocal
- >"%tmp%\j.j" echo;s=WSH.StdIn.ReadLine().replace(/^^.+?\.(bat^|cmd)" /ig,'');
- >>"%tmp%\j.j" echo;WSH.echo(s.replace(/"/g,'').replace(/ (?=[a-z]:)/ig,'\r\n'));
- for /f "delims=" %%a in ('type "%tmp%\t.t"^|cscript -nologo -e:jscript "%tmp%\j.j"') do (
- if exist "%%a\" (
- del /f /q /ah "%%a\desktop.ini" 2>nul
- set "f="
- for /f "delims=" %%b in ('dir /a-d/b "%%a\*.ico" 2^>nul') do (
- set f=1
- (echo;[.ShellClassInfo]
- echo;IconResource=%%b
- echo;[ViewState]
- echo;Mode=
- echo;Vid=
- echo;FolderType=Pictures)>"%%a\desktop.ini"
- attrib +s +h "%%a\%%b"
- attrib +s +h "%%a\desktop.ini"
- attrib +r "%%a"
- )
- if not defined f (
- for /f "delims=" %%c in ("%%a") do echo;找不到文件 - "%%~nxc"
- )
- )
- )
- :end
- echo;
- pause
- exit
复制代码
目的是一次性给所有拖入文件夹挂上图标(图标在文件夹内)
之前修改后可以处理特殊符号(如&)。现在又遇到问题了:文件名含有"・"会被传递成"?"
求解决
错误信息:
文件夹名:・・・
del /f /q /ah "C:\Users\sword\Desktop\???\desktop.ini" 2>nul
set "f="
for /F "delims=" %b in ('dir /a-d/b "C:\Users\sword\Desktop\???\*.ico" 2>nul') do (
set f=1
作者: sykIII 时间: 2019-11-7 20:47
回复 3# flashercs
闪退跳出,运行不了啊
欢迎光临 批处理之家 (http://bathome.net./) |
Powered by Discuz! 7.2 |