Jump to content

Save File Details Property Using Auto IT Script?


Recommended Posts

HI, I'm new to autoit and i'm developing some codes to edit the tags of Mp3, m4a and wma and duplication of files and update tags with every duplications.

Here is my script

#include-once

#include <GUIConstantsEx.au3>

#include <ButtonConstants.au3>

#include <ListboxConstants.au3>

#Include <GuiStatusBar.au3>

#Include <GuiListView.au3>

#include <EditConstants.au3>

#include <ProgressConstants.au3>

#include <File.au3>

#NoTrayIcon

Global Const $SHOP_FILEPATH = 0x00000002

Global $sTab = "AudioShell Tag Editor"

Local $Dirc, $check, $size, $tsize, $info1

Local $var , $tempvar, $nuF

Local $num , $nuFold

Local $num2

Local $num3

Local $loop

Local $loop2

Local $name

Local $prograss

Local $percent

Local $sFile

Local $id3tags

Local $tagBut

$Window = GUICreate("File Duplicator v2.0 OEM", 380, 350, @DesktopHeight / 5.5, @DesktopWidth / 6)

$StatusBar = _GUICtrlStatusBar_Create($Window, -1, -1)

_GUICtrlStatusBar_SetText($StatusBar , "Status")

GUICtrlCreateTab(0,0,1500,1400)

GUICtrlCreateTabItem("Duplicate File")

GUICtrlCreateGroup("Select Source Media File",10,36,360,230)

;GUICtrlCreateLabel("Select Source Media File", 18, 36, 257, 21)

$Location1 = GUICtrlCreateInput("", 18, 56, 237, 21)

$SoundFile = GUICtrlCreateButton("Browse", 272, 56, 67, 20, 0) ;set the file to duplicate

GUICtrlCreateLabel("Select Destination Directory", 18, 86, 257, 21)

$Location2 = GUICtrlCreateInput("", 18, 106, 237, 21)

$DestinationFolder = GUICtrlCreateButton("Browse", 272, 106, 67, 20, 0) ; set the destination file to save duplicated file

GUICtrlCreateLabel("Folders", 18, 136, 257, 18)

$Location4 = GUICtrlCreateInput("1", 18, 156, 42, 18, 0) ;number of song per album

GUICtrlCreateLabel("Files In Folder", 128, 136, 257, 21)

$Location3 = GUICtrlCreateInput("1", 128, 156, 42, 18, 0) ;number of loop to run duplication

$duplicate = GUICtrlCreateButton("Start", 272, 156, 67, 25, 0) ;duplicate function start button

$DeleteDup = GUICtrlCreateButton("Delete", 272, 186, 67, 25, 0) ;duplicate function start button

GUICtrlCreateLabel("Duplication Progress",18,220,100,20)

$progress = GUICtrlCreateProgress(18,240,320,15)

GUICtrlCreateTabItem("Get Tags")

$getID3info = GUICtrlCreateButton("Get ID3 Info", 20, 35, 70, 20)

$clear = GUICtrlCreateButton("Clear", 100, 35, 70, 20)

$saveTag = GUICtrlCreateButton("Save Tag", 180, 35, 70, 20)

GUICtrlCreateGroup("ID3",20,55,300,245)

$StatusBar = _GUICtrlStatusBar_Create($Window, -1, -1)

_GUICtrlStatusBar_SetText($StatusBar , "Status")

$Title_label = GUICtrlCreateLabel("Title:", 40, 70, 50, 20)

$Title_input = GUICtrlCreateInput("", 40, 85, 240, 20)

$Artist_label = GUICtrlCreateLabel("Artist:", 40, 80+30, 50, 20)

$Artist_input = GUICtrlCreateInput("", 40, 80+45, 220, 20)

$Album_label = GUICtrlCreateLabel("Album:", 40, 130+20, 50, 20)

$Album_input = GUICtrlCreateInput("", 40, 130+35, 220, 20)

$Genre_label = GUICtrlCreateLabel("Genre", 40, 195, 50, 20)

$Genre_input = GUICtrlCreateInput("", 40, 170+40, 220, 20)

$Comment_label = GUICtrlCreateLabel("Comment", 40, 235, 50, 20)

$Comment_edit = GUICtrlCreateEdit( "", 40, 250, 220, 40)

GUISetState(@SW_SHOW)

While 1

$msg = GUIGetMsg()

Switch $msg

Case $GUI_EVENT_CLOSE

_DLLshutdown()

Exit

Case $SoundFile

$var = FileOpenDialog ( "Choose MP3 or WAV File", "", "MP3 files (*.mp3)|WMA files (*.wma) |M4a files (*.m4a)|All Files (*.*)", 4 )

GUICtrlSetData($Location1, $var)

FileDelete($tempvar)

Case $DestinationFolder

$Dirc = FileSelectFolder("Select Destionaion File","")

GUICtrlSetData($Location2, $Dirc)

; Case $tagBut

; if($var = "") then

; msgbox(48, 'Error', 'Select Media File')

; Else

; saveTags()

; EndIf

Case $getID3Info

if($var = "") then

msgbox(48, 'Error', 'Select Media File')

Else

saveTags()

_readID3Info()

EndIf

Case $duplicate

if($var = "") then

msgbox(48, 'Error', 'Select Media File')

elseif($dirc ="") then

msgbox(48, 'Error', 'Select Destination Directory')

else

saveDic()

Endif

Case $DeleteDup

deleteDup()

EndSwitch

WEnd

Func saveDic()

_GUICtrlStatusBar_SetText( $StatusBar , "In Prograss ...")

$prograss =0

$num3 = GUICtrlRead($location3) ;file in folder

$num2 = GUICtrlRead($location4) ;number of folder

$sFile = $var

$sFile = StringRegExpReplace($sFile, "^.*\\(.*)$", "$1")

if ($num2=0) Then

msgbox(48, 'Error', 'Folder should be 1 or more')

elseif ($num2 > 0) Then

$size = FileGetSize($var)/1048576

$num=($num3*$num2) ;file in folder x folder

$tsize= Round(($num*$size),2) & " MB"

$confirmBox = msgbox(1+48, 'Warning', 'It will use up to ' & $tsize & ' of HDD space')

If $confirmBox=1 Then

for $loop=1 To ($num2) Step 1

DirCreate($Dirc & "\" & "Album" & $loop)

for $loop2=1 To $num3 Step 1

$name = "\" & $loop2 & " " & $sFile

if ($tempvar="") Then

FileCopy($var, $Dirc & "\" & "Album" & $loop & $name, 8)

else

FileCopy($tempvar, $Dirc & "\" & "Album" & $loop & $name, 8)

EndIf

next

$percent = ($loop*100*$num3)/$num

GUICtrlSetData($progress,$percent)

if ($loop=$num2)Then

msgbox(48, 'Complete', 'Duplicate File Complete')

Endif

next

EndIf

EndIf

_GUICtrlStatusBar_SetText( $StatusBar , "Complete!")

EndFunc

Func saveTags()

$sFile = $var

$sFile = StringRegExpReplace($sFile, "^.*\\(.*)$", "$1")

FileCopy($var, @TempDir & "\Edit Tag For " & $sFile , 8)

$tempvar = @TempDir & "\Edit Tag For " & $sFile

_DLLstartup()

; Global $intReturn = DllCall("shell32.dll", "int", "SHObjectProperties", "hwnd", 0, "dword", _

; $SHOP_FILEPATH, "wstr", $tempvar , "wstr", $sTab)

EndFunc

Func deleteDup()

$nuFold = GUICtrlRead($location4) ;number of folder

msgbox(48, 'Warning', $Dirc)

For $nuF=1 to $nuFold Step 1

DirRemove($Dirc & "\" & "Album" & $nuF,1)

Next

EndFunc

Func _DLLstartup($DLLpath = '')

If $DLLpath = Default Or $DLLpath = '' Then $DLLpath = @ScriptDir & '\AudioShellExt.dll'

RunWait('regsvr32 /s ' & '"' & $DLLpath & '"')

EndFunc ;==>_DLLstartup

Func _DLLshutdown($DLLpath = '')

If $DLLpath = Default Or $DLLpath = '' Then $DLLpath = @ScriptDir & '\AudioShellExt.dll'

RunWait('regsvr32 /u /s ' & '"' & $DLLpath & '"')

EndFunc ;==>_DLLshutdown

Func _GetExtProperty($sPath, $iProp)

Local $iExist, $sFile, $sDir, $oShellApp, $oDir, $oFile, $aProperty, $sPropertym

$iExist = FileExists($sPath)

If $iExist = 0 Then

SetError(1)

Return 0

Else

$sFile = StringTrimLeft($sPath, StringInStr($sPath, "\", 0, -1))

$sDir = StringTrimRight($sPath, (StringLen($sPath) - StringInStr($sPath, "\", 0, -1)))

$oShellApp = ObjCreate ("shell.application")

$oDir = $oShellApp.NameSpace ($sDir)

$oFile = $oDir.Parsename ($sFile)

If $iProp = -1 Then

Local $aProperty[35]

For $i = 0 To 34

$aProperty[$i] = $oDir.GetDetailsOf ($oFile, $i)

Next

Return $aProperty

Else

$sProperty = $oDir.GetDetailsOf ($oFile, $iProp)

If $sProperty = "" Then

Return 0

Else

Return $sProperty

EndIf

EndIf

EndIf

EndFunc ;==>_GetExtProperty

Func _readID3Info()

$tITLE = _GetExtProperty($tempvar, 40)

GUICtrlSetData($Title_input, $tITLE)

$aRTIST = _GetExtProperty($tempvar, 42)

GUICtrlSetData($Artist_input, $aRTIST)

$aLBUM = _GetExtProperty($tempvar, 41)

GUICtrlSetData($Album_input, $aLBUM)

$gENRE = _GetExtProperty($tempvar, 44)

GUICtrlSetData($Genre_input, $gENRE)

$cOMMENT = _GetExtProperty($tempvar, 45)

GUICtrlSetData($Comment_edit, $cOMMENT)

EndFunc

And used Freeware AudioShellExt.dll.

and shell.dll

I could get the detail tags of the media files (mp3, wma, m4a) using

$sProperty = $oDir.GetDetailsOf ($oFile, $iProp)

But I would like to edit (change or delete) that property like we did in window file property dialog. I cannot find any scripts from autoit to set fileproperty into files and save it.

I need to set the data typed in in 2nd tab to save permanently.

Thank You .. pls ignore if there is any mistakes (in language as well) since it is not my native.

Link to comment
Share on other sites

Not the answer but Ctrl+T can be your friend.

i dun get it at all.

I can get the details using getdetailsof by shell.dll. but now i need sth like setdetailsof function to save the tags.

I know there is no function with setdetailsof, but i would like to get the similar way to do it. I'm quite new to VB and autoit so cannot think about it at all.

Posted Image

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...