Page 1 of 2

convert bat to script??

Posted: 24 Apr 2022 11:47
by yogi
hello to all, here I am not computer scientists; but I have .bat files that allow me a lot of things, (I am not the author, I do not understand anything). For example
_create folders from a list of a text file,
_create deskot.ini to illustrate my files with icons inside
_order my files by extensions; (it exists I saw on the forum but I can not trigger it....)
etc.....
.If possible, I would like someone to translate them to me in xyplorer script format (I know it may be asking a lot...); because the person who made them for me doesn't know that and doesn't have the time.
and it might allow me to try to understand the scripts even if I don't understand that at all. if a charitable soul wants to look, I'm attaching some bat file.
thank you very much because I like xyplorer and having everything in a single window would make me better
YOGI
Google Translate

Re: convert bat to script??

Posted: 25 Apr 2022 11:40
by Norn
1)viewtopic.php?f=7&t=18815 There is also a script to create folder from the clipboard.
2)viewtopic.php?f=3&t=24300 ?
3)Can't understand.

Re: convert bat to script??

Posted: 25 Apr 2022 13:08
by yogi
thank you so much for your reply. I had actually seen these topics. But I can't get it to work. here is my file to iconize my windows folder (image instead of the yellow folder). to put it simply, I have an *ico file in my folder, I drag the folder onto .bat and it creates a desktop.ini for me. and a few seconds later, I have the folder with the corresponding icon. Of course if there are several .ico files it takes any.
the advantage is that if i switch to a pc that does not have xyplorer the icon is displayed anyway. is it the same on xyplorer??? for me it does not work in any case with the scripts.
thank you anyway!

@echo off


chcp 1252 >nul
set ICOINI=Desktop.ini

for /f "tokens=* delims=" %%i IN ('dir /s/b /a:d') do (
call :write_File "%%~i"
)

pause>nul&exit
:Write_File <FOLDER>
setlocal EnableDelayedExpansion
if not exist "%~1\*.ico" exit /b 1
attrib +a +s "%~1" /d /s
for %%F in ("%~1\*.ico") do (set "ICO=%%~nxF")
if exist "%~1\%ICOINI%" attrib -a -s -h "%~1\%ICOINI%"
(
echo;[.ShellClassInfo]
echo;ConfirmFileOp=0
echo;IconResource=!ICO!,0
)>"%~1\%ICOINI%"
attrib -a +s +h "%~1\%ICOINI%"
echo;%~1
endlocal
exit /b 0

Re: convert bat to script??

Posted: 26 Apr 2022 22:34
by Norn
Create desktop.ini file for thumbnails in parent folders
$types = "*.jpg;*.png;*.gif"; to $types = "*.jpg;*.png;*.gif;*.ico";

Re: convert bat to script??

Posted: 27 Apr 2022 12:47
by yogi
thank you for this advice, I took this script proposed before and changed the line that you told me; but how should I use this script?? creating a user button? drag and drop??
in fact I do not understand the principle, he must create a destop.ici for me?? because I don't care, he writes to me at the end: no change found...
then I must make a handling or usage error.
I do have an .ico file in my test folder.

Re: convert bat to script??

Posted: 27 Apr 2022 14:53
by Norn
:arrow:

Re: convert bat to script??

Posted: 27 Apr 2022 20:30
by yogi
Cool. Exactly what I'm trying to do. I'm looking to understand my mistake...

Re: convert bat to script??

Posted: 27 Apr 2022 21:23
by yogi
its not ok .... i dont understand the problem ..... only my batch is ok ....

Re: convert bat to script??

Posted: 27 Apr 2022 22:52
by yogi
I understood, it is necessary the system files attribute of check. and it works. how to integrate this attribute in the script??

Re: convert bat to script??

Posted: 28 Apr 2022 19:26
by Norn
Can't understand...

Re: convert bat to script??

Posted: 28 Apr 2022 23:09
by yogi
I would like by a script to put the folder in attribute System

Re: convert bat to script??

Posted: 29 Apr 2022 20:06
by Norn
For windows explorer? :arrow:

Re: convert bat to script??

Posted: 29 Apr 2022 21:30
by yogi
Yes. I see that now

Re: convert bat to script??

Posted: 29 Apr 2022 23:02
by yogi
thank you, I have simplified the thing, but still 2 questions,
is it possible to put more than one format?? icon; exe; png?? etc, and is it possible to do this even for recursive subfolders???
thank you for your time

foreach($folder, <get SelectedItemsPathNames <crlf>>, <crlf>, "e") {
$image = quicksearch("*.ico /limit=1", $folder);

if !(exists($image)) { continue; }
attrstamp("s", , $folder);

$image_relative_path = replace($image, $folder . "\", "");
$DesktopIni = $folder . "\Desktop.ini";

$content = <<<>>>
[.ShellClassInfo]
ConfirmFileOp=0
IconResource=$image_relative_path,0
>>>;
writefile($DesktopIni, $content, , "utf8");
attrstamp("h", , $DesktopIni);
}
status "!!Icone ok!!";

Re: convert bat to script??

Posted: 29 Apr 2022 23:13
by highend
is it possible to put more than one format
*.{ext_1};*.{ext_2};*.{ext_x}?
and is it possible to do this even for recursive subfolders
Wrap everything in another loop that used quicksearch() to find all subfolders?