I have a batch that create shortcut based on the order of files, the problem is that when it comes to numbers he presents the following problem when passing the number 100.
01.mp4
02.mp4
03.rmvb
04.mp4
05.rmvb
06.rmvb
07.rmvb
08.rmvb
09.rmvb
10.rmvb
100.mp4
101.mp4
102.mp4
103.mp4
104.mp4
105.mp4
106.mp4
107.mp4
108.mp4
109.mp4
11.rmvb
I searched here and found various methods however the script I use works with folders and files that sometimes use accents, & and/or !
Example: C:Séries & MoviesRemix!.mkv (Brazil and use E place of and).
I wonder if there is any way to check the content and organize it can be properly before you save it in .ini or after saving the same in .ini.
Observations:
- The folder path is loaded the first time the Set command.
- After entering the path he saved in an .ini file and always loaded.
- The Script list only files within the directory does not list subfolders and files and folders within it.
- The script needs other files to work the download link is below: https://www.mediafire.com/?zcoybkfo8k4nm1t
My Full Code:
@Echo off
Title Create shortcuts in alphabetical order
mode con:lines=3 cols=25
Color 1f
CD /D "%~dp0"
If Exist "Filescommand.ini" For /f "usebackq delims=" %%x in ("Filescommand.ini") do (set "%%x")
If Exist "FilesConfig.ini" For /f "usebackq delims=" %%x in ("FilesConfig.ini") do (set "%%x")
If Exist "FilesFiles.ini" Goto shortcuts
If Exist "Filescommand.ini" Goto shortcuts
If Exist "FilesConfig.ini" Goto shortcuts
for %%F in (""%1"") do Set "location-of-files=%%~F"
for %%F in ("%location-of-files%") do IF "%%~F" NEQ """" Set "location-of-files=%location-of-files:"=%" & Set Number=1 & Goto LocationofFiles2
:LocationofFiles
mode con:lines=18 cols=78
Set "location-of-files=r1u4unoiwqa6">nul 2>&1
cls
echo Location of Files
Set /p location-of-files="ˉ Location of Files: "
Set "location-of-files=%location-of-files:"=%"
Set Number=1
IF "%location-of-files%"=="r1u4unoiwqa6" Goto LocationofFiles
:LocationofFiles2
mode con:lines=18 cols=78
Set "Menu=">nul 2>&1
cls
for %%F in ("%location-of-files%") do Echo %%~F
echo 1(Yes) 2(No)
Set/p Menu="ˉ Menu: "
IF "%Menu%"=="1" Goto Iniciar
IF "%Menu%"=="2" Goto LocationofFiles
Goto LocationofFiles2
:Iniciar
if not exist "%location-of-files%" Cls & Start /Wait FilesError.vbs & Goto LocationofFiles
:Name-AnimeSerie1
Set "Serie_Anime=">nul 2>&1
cls
echo Name Serie
Set /p Serie_Anime="ˉ Name: "
IF "%Serie_Anime%"=="" Goto Name-AnimeSerie1
:Name-AnimeSerie2
Set "Menu=">nul 2>&1
cls
for %%F in ("%Serie_Anime%") do Echo %%~F
echo 1(Yes) 2(No)
Set/p Menu="ˉ Menu: "
IF "%Menu%"=="1" Goto shortcuts
IF "%Menu%"=="2" Goto Name-AnimeSerie1
Goto Name-AnimeSerie2
:shortcuts
If Exist "FilesConfig.ini" For /f "usebackq delims=" %%x in ("FilesConfig.ini") do (set "%%x")
If Not Exist "%location-of-files%" Del /q "C:Users\%username%Desktop\%ep2% - %Serie_Anime%.lnk">nul 2>&1 & Start /Min /Wait FilesDesktopRefresh.exe>nul 2>&1 & Goto end
Dir /a-d /b "%location-of-files%" >FilesFiles.ini
Echo r1u4unoiwqa6.ending >>FilesFiles.ini
Start "exclamation01" /Min /Wait "Filesexclamation01.vbs">nul 2>&1
Set location-of-files > FilesConfig.ini
Set Serie_Anime >> FilesConfig.ini
Set Number > Filescommand.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 FilesDesktopRefresh.exe>nul 2>&1
setlocal EnableDelayedExpansion
For /f "usebackq delims=" %%x in ("Filescommand.ini") do (set "%%x")
For /f "usebackq delims=" %%x in ("FilesConfig.ini") do (set "%%x")
set "cmd=findstr /R /N "^^" FilesFiles.ini | find /C ":""
for /f %%a in ('!cmd!') do set Numbers=%%a
set lines=%Number%
set Atual=1
for /f "delims=" %%a in ('type FilesFiles.ini') do (
for %%b in (!lines!) 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 > Filescommand.ini
Set Ep2 >> Filescommand.ini
Set lines >> Filescommand.ini
Set Number >> Filescommand.ini
endlocal
Start "exclamation02" /Min /Wait "Filesexclamation02.vbs">nul 2>&1
For /f "usebackq delims=" %%x in ("Filescommand.ini") do (set "%%x")
For /f "usebackq delims=" %%x in ("FilesConfig.ini") do (set "%%x")
IF "%Ep2%"=="r1u4unoiwqa6" Goto end
Start /Min /Wait FilesShortcut.exe /F:"C:Users\%username%Desktop\%ep2% - %Serie_Anime%.lnk" /A:C /t:"%location-of-files%\%Ep1%" /D:"Episode %Serie_Anime%">nul 2>&1
If Not Exist "C:Users\%username%Desktop[ shortcuts ].lnk" Echo %Serie_Anime%>Filesshortcut.ini & Start /Min /Wait Filesshortcut.vbs>nul 2>&1
Set /A Number = %lines% + 1
:::::::::::::::::::::::::::::::::::::::::::::
Set location-of-files > FilesConfig.ini
Set Serie_Anime >> FilesConfig.ini
:::::::::::::::::::::::::::::::::::::::::::::
Set Ep1 > Filescommand.ini
Set Ep2 >> Filescommand.ini
Set Number >> Filescommand.ini
:::::::::::::::::::::::::::::::::::::::::::::
Exit
:end
If Not Exist "%location-of-files%" Start /Wait FilesPDoM.vbs>nul 2>&1
If Exist "%location-of-files%" Start /Wait Filesending.vbs>nul 2>&1
If Exist "%location-of-files%" Start "Anime" "%location-of-files%">nul 2>&1
Del /q "FilesFiles.ini">nul 2>&1
Del /q "Filesshortcut.ini">nul 2>&1
Del /q "Filescommand.ini">nul 2>&1
Del /q "FilesConfig.ini">nul 2>&1
Set "location-of-files=">nul 2>&1
Set "Serie_Anime=">nul 2>&1
Set "lines=">nul 2>&1
Set "Ep1=">nul 2>&1
Set "Ep2=">nul 2>&1
Goto LocationofFiles
Part where you need to use the DIR:
:shortcuts
If Exist "FilesConfig.ini" For /f "usebackq delims=" %%x in ("FilesConfig.ini") do (set "%%x")
If Not Exist "%location-of-files%" Del /q "C:Users\%username%Desktop\%ep2% - %Serie_Anime%.lnk">nul 2>&1 & Start /Min /Wait FilesDesktopRefresh.exe>nul 2>&1 & Goto end
Dir /a-d /b "%location-of-files%" >FilesFiles.ini
Echo r1u4unoiwqa6.ending >>FilesFiles.ini
Start "exclamation01" /Min /Wait "Filesexclamation01.vbs">nul 2>&1
Set location-of-files > FilesConfig.ini
Set Serie_Anime >> FilesConfig.ini
Set Number > Filescommand.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 FilesDesktopRefresh.exe>nul 2>&1
setlocal EnableDelayedExpansion
For /f "usebackq delims=" %%x in ("Filescommand.ini") do (set "%%x")
For /f "usebackq delims=" %%x in ("FilesConfig.ini") do (set "%%x")
set "cmd=findstr /R /N "^^" FilesFiles.ini | find /C ":""
for /f %%a in ('!cmd!') do set Numbers=%%a
set lines=%Number%
set Atual=1
for /f "delims=" %%a in ('type FilesFiles.ini') do (
for %%b in (!lines!) 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 > Filescommand.ini
Set Ep2 >> Filescommand.ini
Set lines >> Filescommand.ini
Set Number >> Filescommand.ini
endlocal
See Question&Answers more detail:osThanks in advance.