createIndex.bat

创建本地链接HTML文件脚本
该博客提供了一个创建本地链接HTML文件的脚本。脚本可根据输入的过滤器和文件名生成HTML文件,文件中包含创建日期、CMD路径、过滤器等信息,还会列出匹配的文件链接,若未指定文件名则默认为index.html。

@echo off

if ""%1""=="""" goto useAge
if "%1"=="/?" goto useAge
if "%1"=="?" goto useAge
if "%1"=="/h" goto useAge
if "%1"=="/H" goto useAge
if ""%2""=="""" goto defaultFile
set fileName=%2
goto begin

:defaultFile
set fileName=index.html

:begin
if exist %fileName% goto existError
set tempFile=%temp%/~dir.txt
echo Creating file "%fileName%", please wait...
dir /b/s %1 >%tempFile%
echo ^<html^>^<head^>^<title^>index^</title^>^</head^>^<body onload="window.focus();"^> >%fileName%
echo Create date: %date% %time%>>%fileName%
echo ^<br^>CMD path: >>%fileName%
cd   >>%fileName%
echo ^<br^>Filter: %1>>%fileName%
echo ^<br^>Count: ^<b id="counter"^>^</b^> >>%fileName%
echo ^<div style="display:none"^> >>%fileName%
for /F "tokens=*" %%i in (%tempFile%) do  @echo ^<span^>%%i^</span^> >>%fileName%
echo ^</div^> >>%fileName%
echo ^<script language="javascript"^> >>%fileName%
echo ^<!-- >>%fileName%
echo  var objs=document.body.getElementsByTagName("SPAN");>>%fileName%
echo  var fp=null;>>%fileName%
echo  document.write("<table align='center' cellspacint='0' cellpadding='0' border='1' bordercolor='teal' bordercolordark='white'>");>>%fileName%
echo  for(var i=0;i^<objs.length;i++){>>%fileName%
echo      fp=objs[i].innerText;>>%fileName%
echo      document.write("<tr bgcolor="+(i%%2==0?"FAFAF0":"F0FAFA")+"><td>"+(i+1)+"<td nowrap>"+fp.link(fp));>>%fileName%
echo  }>>%fileName%
echo  document.write("</table>");>>%fileName%
echo  counter.innerText=objs.length;>>%fileName%
echo //--^> >>%fileName%
echo ^</script^> >>%fileName%
echo ^</body^>^</html^> >>%fileName%
del %tempFile%
echo Complete!
start %fileName%

goto end

:useAge
echo UseAge: %0 Filter [FileName]
echo    Filter    - match fileName
echo    FileName  - HTML file name
echo                (end with .htm or .html, default with index.html)
echo    Eexample:
echo        %0 *.jpg picture.html
rem pause
goto end

:existError
echo File "%fileName%" has exist, create failed!
:end %fileName% has

rem ---------------------------------------------------------------------------
rem Script for create local-link-HTML_file
rem
rem $
zzf@2003-11-22 $
rem ---------------------------------------------------------------------------

@echo on



UseAge: createIndex Filter [FileName]
   Filter    - match fileName
   FileName  - HTML file name
               (end with .htm or .html, default with index.html)
   Eexample:
       createIndex *.jpg picture.html


创建索引文件:(脚本略加了分行修改)
MongoDB 提供了 `db.collection.createIndex()` 方法用于为集合的字段创建索引,以提高查询性能。以下是关于该方法的详细使用指南: 索引可以通过指定一个或多个字段及其排序顺序来创建,其中 `1` 表示升序,而 `-1` 表示降序。例如,要为 `mobile` 和 `name` 两个字段创建联合唯一索引,可以使用如下命令: ```javascript db.collection_name.createIndex({ "mobile": 1, "name": 1 }, { unique: true }) ``` 在这个例子中,`unique` 是一个可选参数,它确保索引中的键值在指定字段组合下是唯一的。如果不需要唯一性约束,则可以省略此选项。 另外,创建索引时还可以指定其他选项,比如 `background` 参数允许在后台构建索引,这样可以在创建索引的过程中继续处理数据库操作: ```javascript db.collection.createIndex({ a: 1 }, { background: true }) ``` 此外,`sparse` 选项可用于创建稀疏索引,这意味着索引只会包含那些具有指定字段的文档。如果设置为 `true`,则不会为缺少该字段的文档创建索引条目: ```javascript db.collection.createIndex({ fieldName: 1 }, { sparse: true }) ``` 默认情况下,MongoDB 会自动生成索引名称,但也可以通过 `name` 参数自定义索引名称: ```javascript db.collection.createIndex({ fieldName: 1 }, { name: "custom_index_name" }) ``` 对于复合索引(即涉及多个字段的索引),MongoDB 会根据索引字段的名称和排序顺序自动生成名称,但如果需要特定的名称,同样可以通过 `name` 参数指定。 当执行 `createIndex` 操作时,应该考虑到当前数据库的工作负载,因为创建大型索引可能会消耗资源并影响性能。因此,在生产环境中,通常推荐在低峰期进行索引创建操作,或者总是使用 `background: true` 来减少对数据库性能的影响。 ### 创建索引注意事项 - 在创建索引之前,应评估数据分布和查询模式,以确定最有效的索引策略。 - 对于写入密集型的应用程序,过多的索引可能会影响性能,因为每次插入或更新文档时都需要维护索引。 - 定期审查和优化索引,以确保它们仍然符合应用程序的需求。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值