convert bat to script??

Discuss and share scripts and script files...
yogi
Posts: 118
Joined: 18 Feb 2010 09:05

convert bat to script??

Post 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
XYplorer Version: 27.20.0900 (32-bit)
Windows Version: windows 10 21h2 19044.2006
Screen Scaling Percentage: 100%

Norn
Posts: 508
Joined: 24 Oct 2021 16:10

Re: convert bat to script??

Post 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.
Windows 11 24H2 @100% 2560x1440

yogi
Posts: 118
Joined: 18 Feb 2010 09:05

Re: convert bat to script??

Post 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
XYplorer Version: 27.20.0900 (32-bit)
Windows Version: windows 10 21h2 19044.2006
Screen Scaling Percentage: 100%

Norn
Posts: 508
Joined: 24 Oct 2021 16:10

Re: convert bat to script??

Post by Norn »

Create desktop.ini file for thumbnails in parent folders
$types = "*.jpg;*.png;*.gif"; to $types = "*.jpg;*.png;*.gif;*.ico";
Windows 11 24H2 @100% 2560x1440

yogi
Posts: 118
Joined: 18 Feb 2010 09:05

Re: convert bat to script??

Post 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.
XYplorer Version: 27.20.0900 (32-bit)
Windows Version: windows 10 21h2 19044.2006
Screen Scaling Percentage: 100%

Norn
Posts: 508
Joined: 24 Oct 2021 16:10

Re: convert bat to script??

Post by Norn »

:arrow:
To see the attached files, you need to log into the forum.
Windows 11 24H2 @100% 2560x1440

yogi
Posts: 118
Joined: 18 Feb 2010 09:05

Re: convert bat to script??

Post by yogi »

Cool. Exactly what I'm trying to do. I'm looking to understand my mistake...
XYplorer Version: 27.20.0900 (32-bit)
Windows Version: windows 10 21h2 19044.2006
Screen Scaling Percentage: 100%

yogi
Posts: 118
Joined: 18 Feb 2010 09:05

Re: convert bat to script??

Post by yogi »

its not ok .... i dont understand the problem ..... only my batch is ok ....
XYplorer Version: 27.20.0900 (32-bit)
Windows Version: windows 10 21h2 19044.2006
Screen Scaling Percentage: 100%

yogi
Posts: 118
Joined: 18 Feb 2010 09:05

Re: convert bat to script??

Post by yogi »

I understood, it is necessary the system files attribute of check. and it works. how to integrate this attribute in the script??
XYplorer Version: 27.20.0900 (32-bit)
Windows Version: windows 10 21h2 19044.2006
Screen Scaling Percentage: 100%

Norn
Posts: 508
Joined: 24 Oct 2021 16:10

Re: convert bat to script??

Post by Norn »

Can't understand...
Windows 11 24H2 @100% 2560x1440

yogi
Posts: 118
Joined: 18 Feb 2010 09:05

Re: convert bat to script??

Post by yogi »

I would like by a script to put the folder in attribute System
XYplorer Version: 27.20.0900 (32-bit)
Windows Version: windows 10 21h2 19044.2006
Screen Scaling Percentage: 100%

Norn
Posts: 508
Joined: 24 Oct 2021 16:10

Re: convert bat to script??

Post by Norn »

For windows explorer? :arrow:
To see the attached files, you need to log into the forum.
Windows 11 24H2 @100% 2560x1440

yogi
Posts: 118
Joined: 18 Feb 2010 09:05

Re: convert bat to script??

Post by yogi »

Yes. I see that now
XYplorer Version: 27.20.0900 (32-bit)
Windows Version: windows 10 21h2 19044.2006
Screen Scaling Percentage: 100%

yogi
Posts: 118
Joined: 18 Feb 2010 09:05

Re: convert bat to script??

Post 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!!";
XYplorer Version: 27.20.0900 (32-bit)
Windows Version: windows 10 21h2 19044.2006
Screen Scaling Percentage: 100%

highend
Posts: 14940
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: convert bat to script??

Post 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?
One of my scripts helped you out? Please donate via Paypal

Post Reply