根据文件顺序创建快捷方式 [英] Create Shortcut based on the order of files

查看:90
本文介绍了根据文件顺序创建快捷方式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道如何根据文件列表中的名字按字母顺序创建快捷方式.

I wonder how to make a shortcut based on the next name in the file list in alphabetical order.

Folder:

C:\Series

Season01 - Ep01.avi
Season01 - Ep02.avi
Season02 - Ep01.avi
Season02 - Ep02.avi
Season03 - Ep01.avi
Season04 - Ep01.avi

Desktop:

Season01 - Ep02.lnk

打开文件时,它会删除快捷方式 Season01-Ep02.lnk ,并为 Season03-Ep01.lnk 创建新的快捷方式,依此类推.

When opening the file it deletes the shortcut Season01 - Ep02.lnk and create a new shortcut to Season03 - Ep01.lnk and so on.

@编辑

被问到,这是我的超级不完整代码.

As I was asked, here is my super incomplete code.

Sub Main()

Set wsc = CreateObject("WScript.Shell")
Set Shell = CreateObject("WScript.Shell")
Set fso = WScript.CreateObject("Scripting.FileSystemObject")

Const ForReading = 1, ForWriting = 2, ForAppending = 8, CreateIfNeeded = True

Set objFSO = CreateObject("Scripting.FileSystemObject")

Set objTextFile = objFSO.OpenTextFile("Local.ini", ForReading)

For i = 4 to 3
    objTextFile.ReadLine
Next

strLine = objTextFile.ReadLine

Set objTextFile = objFSO.OpenTextFile("Episode.ini", ForReading)

For i = 4 to 3
    objTextFile.ReadLine
Next

strLine2 = objTextFile.ReadLine

Set objTextFile = objFSO.OpenTextFile("Season.ini", ForReading)

For i = 4 to 3
    objTextFile.ReadLine
Next

strLine3 = objTextFile.ReadLine
DesktopPath = Shell.SpecialFolders("Desktop")


If (fso.FileExists(wsc.SpecialFolders("desktop") & "\Season01 - Ep01.lnk")) Then

Set link = Shell.CreateShortcut(DesktopPath & "\Season"& strLine3--01 &" - Ep" & strLine2--01 & ".lnk")
link.Description = "Episode"
link.Arguments = ""
link.TargetPath = strLine & "\Season"& strLine3--01 &" - Ep"& strLine2--01 &".rmvb"
link.WindowStyle = 1
link.IconLocation = strLine & "\Season"& strLine3--01 &" - Ep"& strLine2--01 &".rmvb"
link.HotKey = ""
link.WorkingDirectory = strLine
link.Save

strAtalho = "Season"& strLine3-01 &" - Ep"& strLine2-01 &".rmvb"
Set objShell = CreateObject("WScript.Shell") 
objDesktop = objShell.SpecialFolders("Desktop") 
Set objFSO = CreateObject("Scripting.FileSystemObject") 
objFSO.DeleteFile(objDesktop & "\" & strAtalho)

  WScript.Quit()

Else

End If

  WScript.Quit()

End Sub 

On Error Resume Next
  Main
  If Err.Number Then
     WScript.Quit 4711
  End If

-

内部存档:

Inside archives:

Episode.ini

Episode.ini

01

Season.ini

Season.ini

01

Local.ini

Local.ini

C:\ Series

C:\Series

该代码有几个问题,因为没有自动更改季节,因为当您将唯一数字设置为1、2、3、4、5、6、7、8、9时,不添加0时,请不要验证该文件将创建的快捷方式不存在...

The code has several problems, as no change of season automatically, as not add 0 when you have unique numbers as 1, 2, 3, 4, 5, 6, 7, 8, 9, not verify that the file that will be created shortcut does not exist...

推荐答案

好吧,经过大量搜索,我设法...

Well, after much searching I managed to ...

要使用它,需要以下程序:

To use it will be necessary the following programs:

https://helgeklein.com/downloads/DesktopRefresh/current/x86/DesktopRefresh.zip http://optimumx.com/download/Shortcut.zip

@echo off

If exist "Arquivos\Config.ini" For /f "usebackq delims=" %%x in ("Arquivos\Config.ini") do (set "%%x")

If not Exist "Arquivos\Config.ini" Set /p Localizacao="Enter the file location: " & Set Numeracao=1
Dir /b "%Localizacao%" >"Arquivos\Arquivos.ini"
Echo Fim.Final >>"Arquivos\Arquivos.ini"

:Atalhos

If Exist "C:\Users\%username%\Desktop\%ep2%.lnk" Del /q "C:\Users\%username%\Desktop\%ep2%.lnk">nul 2>&1 & Start /Min /Wait Arquivos\DesktopRefresh.exe>nul 2>&1

setlocal EnableDelayedExpansion
set "cmd=findstr /R /N "^^" Arquivos\Arquivos.ini | find /C ":""

for /f %%a in ('!cmd!') do set numeros=%%a

set linhas=%Numeracao%
set curr=1
for /f "delims=" %%a in ('type Arquivos\Arquivos.ini') do (
    for %%b in (!linhas!) do (
        if !curr!==%%b Set Ep1=%%a
    )
    set /a "curr = curr + 1"
)

Set Ep2=%Ep1%
set "find=*."
call set delete=%%Ep2:!find!=%%
call set Ep2=%%Ep2:!delete!=%%
Set Ep2=%Ep2:.=%

IF "%Ep2%"=="Fim" Goto Fim

Arquivos\Shortcut.exe /F:"C:\Users\%username%\Desktop\%ep2%.lnk" /A:C /t:"%Localizacao%\%Ep1%">nul 2>&1
Set /A Numeracao = %linhas% + 1

Set Localizacao > Arquivos\Config.ini
Set Ep2 >> Arquivos\Config.ini
Set Numeracao >> Arquivos\Config.ini
exit

:Fim

Set Numeracao=1

If Exist "C:\Users\%username%\Desktop\%ep2%.lnk" Del /q "C:\Users\%username%\Desktop\%ep2%.lnk">nul 2>&1 & Start /Min /Wait Arquivos\DesktopRefresh.exe>nul 2>&1

setlocal EnableDelayedExpansion
set "cmd=findstr /R /N "^^" Arquivos\Arquivos.ini | find /C ":""

for /f %%a in ('!cmd!') do set numeros=%%a

set linhas=1
set curr=1
for /f "delims=" %%a in ('type Arquivos\Arquivos.ini') do (
    for %%b in (!linhas!) do (
        if !curr!==%%b Set Ep1=%%a
    )
    set /a "curr = curr + 1"
)

Set Ep2=%Ep1%
set "find=*."
call set delete=%%Ep2:!find!=%%
call set Ep2=%%Ep2:!delete!=%%
Set Ep2=%Ep2:.=%

Arquivos\Shortcut.exe /F:"C:\Users\%username%\Desktop\%ep2%.lnk" /A:C /t:"%Localizacao%\%Ep1%">nul 2>&1
Set /A Numeracao = 1 + 1

Set Localizacao > Arquivos\Config.ini
Set Ep2 >> Arquivos\Config.ini
Set Numeracao >> Arquivos\Config.ini
Exit

  • 将脚本放置在文件夹中,将程序放置在名为"Arquivos"的文件夹中
  • 订单将保持原状
  • Script.bat
  • 文件夹-Arquivos
  • 在文件夹中:DesktopRefresh.exe和Shortcut.exe
    • Place the script in a folder and programs in a folder called "Arquivos"
    • The Order will stay that way
    • Script.bat
    • Folder - Arquivos
    • Within the folder: DesktopRefresh.exe and Shortcut.exe
    • 注意:尽管不是最终版本,但它可以与任何类型的文件完美配合.

      Note: Although not the final version it works perfectly with any type of file.

      @编辑

      我刚刚为那些需要相同下载的用户完成了脚本,如下所示: https://www.mediafire.com/?w46t526jjth8drd

      I just finished the script for those who want the same download is below: https://www.mediafire.com/?w46t526jjth8drd

      如果下载失败,则下面是源代码

      注意:同一工作需要其他文件.

      @Echo off
      Title Criar atalhos em ordem alfab‚tica
      mode con:lines=3 cols=25
      Color 1f
      
      CD /D "%~dp0"
      
      If Exist "Arquivos\Comando.ini" For /f "usebackq delims=" %%x in ("Arquivos\Comando.ini") do (set "%%x")
      If Exist "Arquivos\Config.ini" For /f "usebackq delims=" %%x in ("Arquivos\Config.ini") do (set "%%x")
      If Exist "Arquivos\Arquivos.ini" Goto Atalhos
      If Exist "Arquivos\Comando.ini" Goto Atalhos
      If Exist "Arquivos\Config.ini" Goto Atalhos
      
      for %%F in (""%1"") do Set "Local-dos-Arquivos=%%~F"
      for %%F in ("%Local-dos-Arquivos%") do IF "%%~F" NEQ """" Set "Local-dos-Arquivos=%Local-dos-Arquivos:"=%" & Set Numeracao=1 & Goto LocaldosArquivos2
      
      :LocaldosArquivos
      mode con:lines=18 cols=78
      Set "Local-dos-Arquivos=r1u4unoiwqa6">nul 2>&1
      cls
      echo  ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»
      echo  º  Local dos arquivos  º
      echo  ÌÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÊÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»
      echo  º ² Arraste a pasta com os arquivos para dentro desta janela ou            º
      echo  º ² digite abaixo a localiza‡Æo da mesma.                                  º
      echo  º ²                                                                        º
      echo  º ² Exemplo: C:\Users\Public\Videos\Animes                                 º
      echo  ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ
      echo.
      Set /p Local-dos-Arquivos="¯ Local dos arquivos: " 
      Set "Local-dos-Arquivos=%Local-dos-Arquivos:"=%"
      Set Numeracao=1
      IF "%Local-dos-Arquivos%"=="r1u4unoiwqa6" Goto LocaldosArquivos
      
      
      :LocaldosArquivos2
      mode con:lines=18 cols=78
      Set "Menu=">nul 2>&1
      cls
      echo  ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»
      echo  º  Local dos arquivos  º
      echo  ÌÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÊÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»
      echo  º ² Est  ‚ a localiza‡Æo da pasta com os arquivos?                         º
      echo  ÌÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ
      echo  º
      for %%F in ("%Local-dos-Arquivos%") do Echo  º ¯ %%~F
      echo  º
      echo  ÌÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»
      echo  º ¯ Menu:                                                                  º
      echo  ÌÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͹
      echo  º ² (1) Sim                                                                º
      echo  º ² (2) NÆo                                                                º
      echo  ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ
      Set/p Menu="¯ Menu: "
      IF "%Menu%"=="1" Goto Iniciar
      IF "%Menu%"=="2" Goto LocaldosArquivos
      Goto LocaldosArquivos2
      
      :Iniciar
      if not exist "%Local-dos-Arquivos%" Cls & Start /Wait Arquivos\Error.vbs & Goto LocaldosArquivos
      
      :Nome-AnimeSerie1
      Set "Serie_Anime=">nul 2>&1
      cls
      echo  ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»
      echo  º  Nome do Anime/S‚rie  º
      echo  ÌÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÊÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»
      echo  º ² Digite abaixo o nome do Anime/S‚rie.                                   º
      echo  º ²                                                                        º
      echo  º ² Exemplo: Shigatsu wa Kimi no Uso                                       º
      echo  ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ
      echo.
      Set /p Serie_Anime="¯ Nome: " 
      IF "%Serie_Anime%"=="" Goto Nome-AnimeSerie1
      
      
      :Nome-AnimeSerie2
      Set "Menu=">nul 2>&1
      cls
      echo  ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»
      echo  º  Nome do Anime/S‚rie  º
      echo  ÌÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÊÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»
      echo  º ² Este ‚ o nome do Anime/S‚rie?                                          º
      echo  ÌÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ
      echo  º
      for %%F in ("%Serie_Anime%") do Echo  º ¯ %%~F
      echo  º
      echo  ÌÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»
      echo  º ¯ Menu:                                                                  º
      echo  ÌÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͹
      echo  º ² (1) Sim                                                                º
      echo  º ² (2) NÆo                                                                º
      echo  ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ
      Set/p Menu="¯ Menu: "
      IF "%Menu%"=="1" Goto Atalhos
      IF "%Menu%"=="2" Goto Nome-AnimeSerie1
      Goto Nome-AnimeSerie2
      
      :Atalhos
      If Exist "Arquivos\Config.ini" For /f "usebackq delims=" %%x in ("Arquivos\Config.ini") do (set "%%x")
      Dir /a-d /b "%Local-dos-Arquivos%" >Arquivos\Arquivos.ini
      Echo r1u4unoiwqa6.Final >>Arquivos\Arquivos.ini
      
      Set Local-dos-Arquivos > Arquivos\Config.ini
      Set Serie_Anime >> Arquivos\Config.ini
      Set Numeracao > Arquivos\Comando.ini
      
      If Exist "C:\Users\%username%\Desktop\%ep2% - %Serie_Anime%.lnk" Del /q "C:\Users\%username%\Desktop\%ep2% - %Serie_Anime%.lnk">nul 2>&1 & Start /Min /Wait Arquivos\DesktopRefresh.exe>nul 2>&1
      
      setlocal EnableDelayedExpansion
      
      For /f "usebackq delims=" %%x in ("Arquivos\Comando.ini") do (set "%%x")
      For /f "usebackq delims=" %%x in ("Arquivos\Config.ini") do (set "%%x")
      
      set "cmd=findstr /R /N "^^" Arquivos\Arquivos.ini | find /C ":""
      
      for /f %%a in ('!cmd!') do set Numeros=%%a
      
      set Linhas=%Numeracao%
      set Atual=1
      for /f "delims=" %%a in ('type Arquivos\Arquivos.ini') do (
          for %%b in (!Linhas!) do (
              if !Atual!==%%b Set Ep1=%%a
          )
          set /a "Atual = Atual + 1"
      )
      
      Set Ep2=%Ep1%
      set "find=*."
      call set delete=%%Ep2:!find!=%%
      call set Ep2=%%Ep2:!delete!=%%
      Set Ep2=%Ep2:.=%
      
      Set Ep1 > Arquivos\Comando.ini
      Set Ep2 >> Arquivos\Comando.ini
      Set Linhas >> Arquivos\Comando.ini
      Set Numeracao >> Arquivos\Comando.ini
      
      endlocal
      For /f "usebackq delims=" %%x in ("Arquivos\Comando.ini") do (set "%%x")
      For /f "usebackq delims=" %%x in ("Arquivos\Config.ini") do (set "%%x")
      
      IF "%Ep2%"=="r1u4unoiwqa6" Goto Fim
      
      Start /Min /Wait Arquivos\Shortcut.exe /F:"C:\Users\%username%\Desktop\%ep2% - %Serie_Anime%.lnk" /A:C /t:"%Local-dos-Arquivos%\%Ep1%" /D:"Epis¢dio de %Serie_Anime%">nul 2>&1
      If Not Exist "C:\Users\%username%\Desktop\[ Atalhos ].lnk" Echo %Serie_Anime%>Arquivos\Atalho.ini & Start /Min /Wait Arquivos\Atalho.vbs>nul 2>&1
      Set /A Numeracao = %Linhas% + 1
      :::::::::::::::::::::::::::::::::::::::::::::
      Set Local-dos-Arquivos > Arquivos\Config.ini
      Set Serie_Anime >> Arquivos\Config.ini
      :::::::::::::::::::::::::::::::::::::::::::::
      Set Ep1 > Arquivos\Comando.ini
      Set Ep2 >> Arquivos\Comando.ini
      Set Numeracao >> Arquivos\Comando.ini
      :::::::::::::::::::::::::::::::::::::::::::::
      Exit
      
      :Fim
      Del /q "Arquivos\Arquivos.ini">nul 2>&1
      Del /q "Arquivos\Atalho.ini">nul 2>&1
      Del /q "Arquivos\Comando.ini">nul 2>&1
      Del /q "Arquivos\Config.ini">nul 2>&1
      Set "Local-dos-Arquivos=">nul 2>&1
      Set "Serie_Anime=">nul 2>&1
      Set "Linhas=">nul 2>&1
      Set "Ep1=">nul 2>&1
      Set "Ep2=">nul 2>&1
      Start /Wait Arquivos\Final.vbs>nul 2>&1
      Goto LocaldosArquivos
      

      这篇关于根据文件顺序创建快捷方式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆