Sign in to follow this  
Followers 0
MykeV

Can AutoIt make it simple

3 posts in this topic

Can anyone help me with ideas in writing a simple script to process the following list of commands in my batch file. I have compressed 7zip files in each of the named folders that i simply want to decompress for some external commands to act on. Thanks in advance.

cmdow @ /HID

@ECHO OFF

SET TARGET=%systemdrive%\Install

7za x 491SP2\*.7z -o%target%\491SP2

7za x AdbRdr\*.7z -o%target%\AdbRdr

7za x IPTV\*.7z -o%target%\IPTV

7za x LNotes\*.7z -o%target%\LNotes

7za x Patchlink\*.7z -o%target%\Patchlink

7za x SAV2021\*.7z -o%target%\SAV2021

7za x Visio\*.7z -o%target%\Visio

7za x Winzip\*.7z -o%target%\Winzip

7za x ZfDAgent\*.7z -o%target%\ZfDAgent

EXIT

Share this post


Link to post
Share on other sites



I'm at work. I don't have 7Zip and a way to test it but this should work. I if it doesn't work at least it will get you start it.

$Target = EnvGet('SystemDrive') & '\Install'

RunWait('7za x 491SP2\*.7z -o' & $Target & '\491SP2', @WorkingDir, @SW_HIDE)
RunWait('7za x AdbRdr\*.7z -o' & $Target & '\AdbRdr', @WorkingDir, @SW_HIDE)
RunWait('7za x IPTV\*.7z -o' & $Target & '\IPTV', @WorkingDir, @SW_HIDE)
RunWait('7za x LNotes\*.7z -o' & $Target & '\LNotes', @WorkingDir, @SW_HIDE)
RunWait('7za x Patchlink\*.7z -o' & $Target & '\Patchlink', @WorkingDir, @SW_HIDE)
RunWait('7za x SAV2021\*.7z -o' & $Target & '\SAV2021', @WorkingDir, @SW_HIDE)
RunWait('7za x Visio\*.7z -o' & $Target & '\Visio', @WorkingDir, @SW_HIDE)
RunWait('7za x Winzip\*.7z -o' & $Target & '\Winzip', @WorkingDir, @SW_HIDE)
RunWait('7za x ZfDAgent\*.7z -o' & $Target & '\ZfDAgent', @WorkingDir, @SW_HIDE)

AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Search any subfolder name for any 7z name programmically.

Using FileFindFirstFile / FileFindNextFile:

; Get the target path
$target = EnvGet('systemdrive') & '\Install'

; Check script workingdir is target path else correct.
If @WorkingDir <> $target Then
    FileChangeDir($target)
EndIf

$handle_search_root = FileFindFirstFile('*')
If $handle_search_root <> -1 Then
    While 1
        $file_root = FileFindNextFile($handle_search_root)
        If @error Then ExitLoop
        If StringInStr(FileGetAttrib($file_root), 'D') Then
            ; Found a folder so change workingdir and search for 7z files
            If FileChangeDir($file_root) Then
                $handle_search_subfolder = FileFindFirstFile('*.7z')
                If $handle_search_subfolder <> -1 Then
                    While 1
                        $file_subfolder = FileFindNextFile($handle_search_subfolder)
                        If @error Then ExitLoop
                        If StringRight($file_subfolder, 3) = '.7z' Then
                            ; Found a 7z file so run it
                            RunWait('7za x "' & @WorkingDir & '\' & $file_subfolder & '" -o"' & $target & '\' & $file_root & '"', @WorkingDir)
                        EndIf
                    WEnd
                    FileClose($handle_search_subfolder)
                EndIf
                ; Back to target workingdir and search another folder
                FileChangeDir('..')
            EndIf
        EndIf
    WEnd
    FileClose($handle_search_root)
EndIf
oÝ÷ ÚÚ½ªâjبÚÊ.²)à
­¢­¶¬¹·è׫±«­¢+Ø(ÀÌØíÑÉÐô¹ÙÐ ÌäíÍåÍѵɥÙÌä줵ÀìÌäìÀäÈí%¹Íѱ°Ìäì((ì
¡¬ÍÉ¥ÁÐݽɭ¥¹¥È¥ÌÑÉÐÁÑ ±Í½ÉÉи)%]½É­¥¹¥È±ÐìÐìÀÌØíÑÉÐQ¡¸(%¥±
¡¹¥È ÀÌØíÑÉФ)¹%((ìÐÑ¡ÍÕ½±ÉÌ(ÀÌØíÍÕ½±ÉÌô}MÕ½±ÉÌ ÀÌØíÑÉФ((ÀÌØíÍÁ±¥ÐôMÑÉ¥¹MÁ±¥Ð ÀÌØíÍÕ½±ÉÌ°
I1°Ä¤)%9½ÐÉɽÈQ¡¸(%½ÈÀÌØí¤ôÄQ¼ÀÌØíÍÁ±¥ÑlÁt($%%¥±
¡¹¥È ÀÌØíÍÁ±¥ÑlÀÌØí¥t¤Q¡¸($$$ÀÌØí¡¹±}ÍÉ ô¥±¥¹¥ÉÍÑ¥± Ìä쨸ÝèÌäì¤($$%%ÀÌØí¡¹±}ÍÉ ±ÐìÐì´ÄQ¡¸($$$%]¡¥±Ä($$$$$ÀÌØí¥±}½Õ¹ô¥±¥¹9áÑ¥± ÀÌØí¡¹±}ÍÉ ¤($$$$%%ÉɽÈQ¡¸á¥Ñ1½½À($$$$%%MÑÉ¥¹I¥¡Ð ÀÌØí¥±}½Õ¹°Ì¤ôÌäì¸ÝèÌäìQ¡¸($$$$$%IÕ¹]¥Ð ÌäìÝéàÅÕ½ÐìÌäìµÀì]½É­¥¹¥ÈµÀìÌäìÀäÈìÌäìµÀìÀÌØí¥±}½Õ¹µÀìÌäìÅÕ½Ðìµ¼ÅÕ½ÐìÌäìµÀìÀÌØíÑÉеÀìÌäìÀäÈìÌäìµÀìÀÌØíÍÁ±¥ÑlÀÌØí¥tµÀìÌäìÅÕ½ÐìÌäì°]½É­¥¹¥È¤($$$$%¹%($$$%]¹($$$%¥±
±½Í ÀÌØí¡¹±}ÍÉ ¤($$%¹%($$%¥±
¡¹¥È Ìä츸Ìäì¤($%¹%(%9áÐ)¹%()á¥Ð()Õ¹}MÕ½±ÉÌ ÀÌØíͽ±ÉAÑ ¤(%1½°ÀÌØí
½±±Ñ¥½¸°ÀÌØí½M

Untested code so be sure to test first. The path could be a concern for where 7zip is located.

:)

Edit:

Fixed typo in code

Edited by MHz

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0