@echo off setlocal enabledelayedexpansion set "source=%cd%" :: Use current directory as the source set "destination=C:\temp\FP" :: Destination directory (where files will be copied to) :: Check if the destination folder exists, create it if it doesn't. if not exist "%destination%" ( mkdir "%destination%" echo Created destination folder: %destination% ) :: Define the list of zip files and their new folder names directly within the script. for %%a in ( "Software\DS_Installer-V6R2024x.HF1.Windows64.zip,001_DS_Installer-V6R2024x.HF1.Windows64" "Software\3DPassport-V6R2024x.HF1.Windows64.zip,002_3DPassport-V6R2024x.HF1.Windows64" "Software\3DDashboard-V6R2024x.HF1.Windows64.zip,003_3DDashboard-V6R2024x.HF1.Windows64" "Software\FederatedSearchFoundation-V6R2024x.HF1.Windows64.zip,004_FederatedSearchFoundation-V6R2024x.HF1.Windows64" "Software\3DSpaceIndex-V6R2024x.HF1.Windows64.zip,005_3DSpaceIndex-V6R2024x.HF1.Windows64" "Software\3DIndexingServer-V6R2024x.HF1.Windows64.zip,006_3DIndexingServer-V6R2024x.HF1.Windows64" "Software\3DSpace-V6R2024x.HF2.Windows64.zip,007_3DSpace-V6R2024x.HF2.Windows64" "Software\3DComment-V6R2024x.HF1.Windows64.zip,008_3DComment-V6R2024x.HF1.Windows64" "Software\3DExplore-V6R2024x.HF2.Windows64.zip,009_3DExplore-V6R2024x.HF2.Windows64" "Software\ENOVIAIPClassificationFoundation-V6R2024x.HF1.Windows64.zip,010_ENOVIAIPClassificationFoundation-V6R2024x.HF1.Windows64" "Software\ENOVIACollaborativeTasksFoundation-V6R2024x.HF1.Windows64.zip,011_ENOVIACollaborativeTasksFoundation-V6R2024x.HF1.Windows64" "Software\ENOVIAEnterpriseChangeManagement-V6R2024x.HF1.Windows64.zip,014_ENOVIAEnterpriseChangeManagement-V6R2024x.HF1.Windows64" "Software\ENOVIAProjectManagementFoundation-V6R2024x.HF1.Windows64.zip,015_ENOVIAProjectManagementFoundation-V6R2024x.HF1.Windows64" "Software\ENOVIAUnifiedX-CADDesignManagement-V6R2024x.HF1.Windows64.zip,017_ENOVIAUnifiedX-CADDesignManagement-V6R2024x.HF1.Windows64" "Software\ENOVIADocumentManagement-V6R2024x.HF1.Windows64.zip,018_ENOVIADocumentManagement-V6R2024x.HF1.Windows64" "Software\3DNotification-V6R2024x.HF1.Windows64.zip,019_3DNotification-V6R2024x.HF1.Windows64" "Software\EXALEAD_CloudView-V6R2024x.HF1.Windows64.zip,020_EXALEAD_CloudView-V6R2024x.HF1.Windows64" "Software\3DSwym-V6R2024x.HF1.Windows64.zip,021_3DSwym-V6R2024x.HF1.Windows64" ) do ( for /F "tokens=1,2 delims=," %%b in ("%%a") do ( echo Copying: %%b copy "%%b" "%destination%\" set "zipfile=%%~nxb" :: Get the name of the zip file (with extension). set "outputfolder=%destination%\%%~nb" :: Create a folder based on the zip file name. set "newfolder=%destination%\%%c" :: Get the new folder name from the list. echo Unzipping: %%b :: Create the output folder if it doesn't exist. if not exist "!outputfolder!" ( mkdir "!outputfolder!" ) :: Unzip the file. powershell -command "Expand-Archive -Path '%destination%\!zipfile!' -DestinationPath '!outputfolder!' -Force" :: Rename the extracted folder to the new name. if exist "!outputfolder!" ( rename "!outputfolder!" "%%c" echo Folder renamed to: %%c ) :: Delete the zip file after extraction. if exist "%destination%\!zipfile!" ( del "%destination%\!zipfile!" echo Deleted zip file: !zipfile! ) ) ) echo Operation completed. pause