标题: 10元求个简单命令:想指定目录写入文件夹配置文件 [打印本页]
作者: sykIII 时间: 2019-12-3 23:22 标题: 10元求个简单命令:想指定目录写入文件夹配置文件
有个目录A,目录A的位置已知,假设为 %A%
现在需要向目录A下的所有文件夹写入这段东西- [.ShellClassInfo]
- IconResource=#.ico
- [ViewState]
- Mode=
- Vid=
- FolderType=Pictures
复制代码
到desktop.ini
并把#.ico和desktop.ini添加attrib +s +h
作者: Batcher 时间: 2019-12-3 23:28
回复 1# sykIII
test.bat- @echo off
- REM 设置待处理的文件夹
- set "DestFolder=D:\Test"
- cd /d "%DestFolder%"
- for /f "delims=:" %%i in ('findstr /n "^:DynamicScript$" "%~f0"') do (
- more +%%i "%~f0" > "%temp%\desktop.ini"
- )
- for /f "delims=" %%i in ('dir /b /s /ad') do (
- copy /y "%temp%\desktop.ini" "%%i\"
- attrib +s +h "%%i\desktop.ini"
- )
- goto :eof
-
- REM 请确保待生成的文本位于脚本的末尾
- :DynamicScript
- [.ShellClassInfo]
- IconResource=#.ico
- [ViewState]
- Mode=
- Vid=
- FolderType=Pictures
复制代码
作者: sykIII 时间: 2019-12-3 23:48
回复 2# Batcher
求这样写复制代码
B是要弄的目录
作者: zaqmlp 时间: 2019-12-4 00:34
- @echo off
- set info=互助互利,支付宝扫码头像,感谢打赏
- rem 有问题,可加QQ956535081及时沟通
- title %info%
- set "rootpath=%~dp0"
- for /f "delims=:" %%a in ('findstr /n "^exit" "%~f0"') do set last=%%a
- for /f "delims=" %%a in ('dir /ad/b/s "%rootpath%"') do (
- if exist "%%a\desktop.ini" (del /a /f /q "%%a\desktop.ini")
- (for /f "skip=%last% delims=" %%b in ('type "%~f0"') do echo;%%b)>"%%a\desktop.ini"
- attrib +s +h "%%a\desktop.ini"
- if exist "%%a\#.ico" (attrib +s +h "%%a\#.ico")
- attrib +r "%%a"
- )
- pause
- exit
- [.ShellClassInfo]
- IconResource=#.ico
- [ViewState]
- Mode=
- Vid=
- FolderType=Pictures
复制代码
作者: Batcher 时间: 2019-12-4 08:57
回复 3# sykIII
@echo off
REM 设置待处理的文件夹
set "A=%~dp0"
set "DestFolder=%A%B"
cd /d "%DestFolder%"
for /f "delims=:" %%i in ('findstr /n "^:DynamicScript$" "%~f0"') do (
more +%%i "%~f0" > "%temp%\desktop.ini"
)
for /f "delims=" %%i in ('dir /b /s /ad') do (
copy /y "%temp%\desktop.ini" "%%i\"
attrib +s +h "%%i\desktop.ini"
)
goto :eof
REM 请确保待生成的文本位于脚本的末尾
:DynamicScript
[.ShellClassInfo]
IconResource=#.ico
[ViewState]
Mode=
Vid=
FolderType=Pictures
作者: sykIII 时间: 2019-12-4 15:59
回复 5# Batcher 复制代码
循环至退出
作者: Batcher 时间: 2019-12-4 20:26
回复 6# sykIII
右键单击bat文件,以管理员身份运行
作者: sykIII 时间: 2019-12-5 22:22
本帖最后由 sykIII 于 2019-12-6 00:02 编辑
回复 7# Batcher
最后一个要求,先删除目录里的desktop.ini,然后把%A%这个目录本身也处理一下
然后希望能和这套命令组合在一起- REM 配置状态
- @echo off
- %1 start "" mshta vbscript:CreateObject("Shell.Application").ShellExecute("cmd.exe","/c ""%~s0"" ::","","runas",1)(window.close)&&exit
- ::
- cls
- set "A=%~dp0"
- ::
- rd /q /s "%USERPROFILE%\Desktop\@控制台"
- mklink /d "%USERPROFILE%\Desktop\@控制台" "%A%User Files\Documents\ctrl_center"
- ::
复制代码
十分感谢
欢迎光临 批处理之家 (http://www.bathome.net/) |
Powered by Discuz! 7.2 |