Overwrite problem Topic is solved

Get help with using AutoHotkey and its commands and hotkeys
Pilu
Posts: 50
Joined: 22 Jun 2018, 01:13

Overwrite problem

05 Jun 2019, 02:25

Hi,

How can i do that when unziping the file and if the name is same , then it doesn't overwrite the file, but also it keeps both all file, and rename filename(2) filename(3) ect..

Code: Select all

#SingleInstance, Force

FileSelectFolder, OutputVar

Loop, Files, % OutputVar "\*.zip", F
{
	Unz(A_LoopFileLongPath, OutputVar "\ext\")
}

Unz(sZip, sUnz) {
	fso := ComObjCreate("Scripting.FileSystemObject")
	
	If (!fso.FolderExists(sUnz)) {
		fso.CreateFolder(sUnz)
	}
	
	psh := ComObjCreate("Shell.Application")
	
	zippedItems := psh.Namespace(sZip).items().count
	
	psh.Namespace(sUnz).CopyHere(psh.Namespace(sZip).items, 4|16)
	
	Loop {
		Sleep, 100
		unzippedItems := psh.Namespace(sUnz).items().count
		ToolTip, Unzipping in progress.. %unzippedItems%/%zippedItems%
		
		If (zippedItems = unzippedItems) {
			ToolTip
			Break
		}
	}
}
User avatar
YoucefHam
Posts: 344
Joined: 24 Aug 2015, 12:56
Facebook: https://fb.me/YoucefHamDz
Google: [email protected]
GitHub: YoucefHam
Location: Algeria
Contact:

Re: Overwrite problem  Topic is solved

10 Jun 2019, 21:15

try this

Code: Select all

#SingleInstance, Force

FileSelectFolder, OutputVar
FileCreateDir, % OutputVar "\ext"
Loop, Files, % OutputVar "\*.zip", F
{
	Unz(A_LoopFileLongPath, OutputVar "\ext\" StrReplace(A_LoopFileName,".zip"))
	i := ""
	Loop
	{
		FileMove, % OutputVar "\ext\" StrReplace(A_LoopFileName,".zip") "\*.*", % OutputVar "\ext\*" (i > 0 ? "_" i : "") ".*", 0
		if !ErrorLevel
			break
		i++
	}
	FileRemoveDir, %  OutputVar "\ext\" StrReplace(A_LoopFileName,".zip"), 1
}

Unz(sZip, sUnz) {
	fso := ComObjCreate("Scripting.FileSystemObject")
	
	If (!fso.FolderExists(sUnz)) {
		fso.CreateFolder(sUnz)
	}
	
	psh := ComObjCreate("Shell.Application")
	
	zippedItems := psh.Namespace(sZip).items().count
	
	psh.Namespace(sUnz).CopyHere(psh.Namespace(sZip).items, 4|16)
	
	Loop {
		Sleep, 100
		unzippedItems := psh.Namespace(sUnz).items().count
		ToolTip, Unzipping in progress.. %unzippedItems%/%zippedItems%
		
		If (zippedItems = unzippedItems) {
			ToolTip
			Break
		}
	}
}
:wave: There is always more than one way to solve a problem. ;)

Return to “Ask For Help”

Who is online

Users browsing this forum: AlexIII, Bing [Bot], CluelessHotKeyUser, mikeyww, murataygun and 41 guests