Jump to content

Read and rename files!


Go to solution Solved by ioa747,

Recommended Posts

Good day,

Firstly, I hope that I have titled this post appropriately?

Secondly, I need to navigate to a selected source folder that contains 1 or more wave data files - the source data.
I need to read that data into an array
• Note: I am "assuming" that this is what I need to do?

Thirdly, from that array, I need to take a master .edl data file and rename that master .edl data file to reflect each-and-every one of the previously selected wave data file(s)
I AM able to do this at present, however there are two problems:

1) I have to use cmd scripts
2) I am unable to choose the destination location for the .edl data file(s)

Here is what I have thus far:

The main script:

; -----------------------------------------------
#include <MsgBoxConstants.au3>
; -----------------------------------------------
_CreateT1Data()
; -----------------------------------------------
Func _CreateT1Data()
    ; Source data
    Local $_sSrcData = MsgBox(4, "NOTICE!", "Create T1 Data from .wav data?")
    ; -----------------
    ; Destination data
    Local $_sDstData = "G:\Session_Master\Show\Session_Data"
    ; -----------------------------------------------
    If $_sSrcData == 6 Then
        Local $sMessageSrc = "Select Source folder..."
        Local $_Selected_Folder = FileSelectFolder($sMessageSrc, "F:\Audio\Type_1\wav")
        ; -----------------
        Local $_wfpath = $_Selected_Folder
        FileWrite($_sDstData & "\path.txt", $_wfpath)
        ; -----------------
        ShellExecute("D:\Developing Shows\Scripts\create_t1_edls.cmd")
        ; -----------------
    ElseIf $_sSrcData == 7 Then
    EndIf
EndFunc   ;==>_CreateT1Data
; -----------------------------------------------

The .cmd script

@echo off & setlocal EnableDelayedExpansion
:: -----------------------------------------------
set _spath1=G:\Session_Master\Show
set _dpath=G:\Session_Master\Show\Session_Data
:: ------
set _file1=wave_file_list.txt
set _file2=Type_1.edl
set _word1=.wav
:: -----------------------------------------------
for /f "delims=" %%i in (%_dpath%\path.txt) do set _wfpath=%content% %%i
:: -----------------------------------------------
dir %_wfpath% /b > %_dpath%\%_file1%
:: -----------------------------------------------
type nul > "%_dpath%\%_file1%.tmp"
for /F "delims=" %%i in ('type "%_dpath%\%_file1%"') do (
  set row=%%i
  set row=!row:%_word1%=%_word2%!
  echo.!row!
) >> "%_dpath%\%_file1%.tmp"
move /y "%_dpath%\%_file1%.tmp" "%_dpath%\%_file1%"
:: -----------------------------------------------
nircmd paramsfile "%_dpath%\%_file1%" "" "" shellcopy "%_dpath%\%_file2%" "%_spath1%\~$fparam.1$.edl" yestoall
:: -----------------------------------------------
del %_dpath%\*.txt /q
del "%_spath1%\*.wpd.edl" /s /q
:: -----------------------------------------------
exit

Any assistance here would be greatly appreciated!

Thank you for your time....appreciated!

Link to comment
Share on other sites

  • Solution

the .cmd script could be replaced with autoit code.

explain to us what nircmd does?

show us Type_1.edl, a .wav file, and the .edl file that nircmd produces for the .wav file
and maybe even nircmd could be bypassed

here is a start

#include <FileConstants.au3>
#include <Array.au3>
#include <MsgBoxConstants.au3>
#include <File.au3>

; ------------------------------------------------------
; Main script to create .edl files from selected .wav files
_CreateT1Data()

Func _CreateT1Data()
    ; Ask the user if they want to create T1 data from .wav data
    Local $confirmCreate = MsgBox(4, "NOTICE!", "Create T1 Data from .wav data?")

    If $confirmCreate = 6 Then ; If "Yes" is selected
        ; Prompt the user to select the source folder containing .wav files
        Local $sourceMessage = "Select Source folder..."
        Local $sourceFolder = FileSelectFolder($sourceMessage, "F:\Audio\Type_1\wav")

        If @error Then
            MsgBox($MB_ICONERROR, "Error", "No folder selected. Exiting.")
            Return
        EndIf

        ; Prompt the user to select the destination folder for the .edl files
        Local $destMessage = "Select Destination folder for .edl files..."
        Local $destFolder = FileSelectFolder($destMessage, "G:\Session_Master\Show")

        If @error Then
            MsgBox($MB_ICONERROR, "Error", "No destination folder selected. Exiting.")
            Return
        EndIf

        ; Store the list of .wav files from the selected source folder
        Local $wavFiles = _FileListToArray($sourceFolder, "*.wav", $FLTA_FILES)

        If @error Then
            MsgBox($MB_ICONERROR, "Error", "No .wav files found in the selected folder.")
            Return
        EndIf

        ; Specify the path to the master .edl file
        Local $masterEdlFile = @ScriptDir & "\Type_1.edl" ;"G:\Session_Master\Show\Session_Data\Type_1.edl"

        If Not FileExists($masterEdlFile) Then
            MsgBox($MB_ICONERROR, "Error", "Master .edl file not found.")
            Return
        EndIf

        ; Process each .wav file and create corresponding .edl file
        For $i = 1 To $wavFiles[0]
            Local $wavFileName = $wavFiles[$i]
            Local $wavBaseName = StringTrimRight($wavFileName, 4) ; Remove the ".wav" extension

            ; Destination .edl file path for each .wav file
            Local $newEdlFile = $destFolder & "\" & $wavBaseName & ".edl"

            ; Copy the master .edl file and rename it for each .wav file
            FileCopy($masterEdlFile, $newEdlFile, $FC_OVERWRITE)
        Next

        MsgBox($MB_ICONINFORMATION, "Success", "All .edl files have been created successfully.")
        
    ElseIf $confirmCreate = 7 Then
        MsgBox($MB_ICONINFORMATION, "Cancelled", "Operation cancelled by the user.")
    EndIf
EndFunc

 

I know that I know nothing

Link to comment
Share on other sites

ioa747,

As always...I greatly appreciate your efforts!!

About Nircmd [Click_Me]

The "paramsfile" command performs the following:

paramsfile [Parameters File] [Delimiters] [Quote Character] [NirCmd Command] 
This powerfull command allows you to execute NirCmd Command multiple times, by loading one or more parameters from a text file. The text file can be comma-delimited, tab-delimited, semicolon-delimited, or delimited by any char that you specify in [Delimiters] parameter. 
Here's an example... Let's say that you have the following text file, containing user names and passwords, delimited by comma: 

user01, 123456
user02, abcfg
user03, 5fr23
user04, 33333

The following NirCmd commands sequence will create 4 users with the specified user-names and passwords (by using 'net user' command provided by Windows 2000/XP operating system) 
nircmd.exe paramsfile "c:\temp\users.txt" "," "" execmd net user ~$fparam.1$ ~$fparam.2$ /add 

The ~$fparam.1$ specifies the first entry in each line - the user name. The ~$fparam.2$ specifies the second entry in each line - the password. 

Examples: 
paramsfile "c:\temp\folders.txt" "" "" execmd md ~$fparam.1$ 
paramsfile "c:\temp\shortcuts.txt" "," "~q" shortcut ~$fparam.1$ "~$folder.desktop$" ~$fparam.2$

ioa747, you stated, "...the .cmd script could be replaced with autoit code..."... Well, it would appear that such a "replacement" is precisely what you have accomplished here!!

I am not at all such what this means...[If indeed this point makes any sense at all?]"...but I seem to be able to "get me head around" batch commands, whereas, I apparently do not have the same degree of success as with the Autoit commands! Rather frustrating!!

Link to comment
Share on other sites

ioa747,

So, here is the completed script...with minor modifications to the source and destination paths...

; ------------------------------------------------------
; With the assistance of...and the gratitude of...ioa747!
; Date: October 19th, 2024
; ------------------------------------------------------
#include <FileConstants.au3>
#include <Array.au3>
#include <MsgBoxConstants.au3>
#include <File.au3>
; ------------------------------------------------------
; Main script to create .edl files from selected .wav files
_CreateT1Data()
; ------------------------------------------------------
Func _CreateT1Data()
    ; Ask the user if they want to create T1 data from .wav data
    Local $confirmCreate = MsgBox(4, "NOTICE!", "Create T1 Data from .wav data?")
    ; ------------------------------------------------------
    If $confirmCreate = 6 Then ; If "Yes" is selected
        ; Prompt the user to select the source folder containing the .wav file data
        Local $sourceMessage = "Select Source folder..."
        Local $sourceFolder = FileSelectFolder($sourceMessage, "F:\Audio\Type_1")
        ; -----------------
        If @error Then
            MsgBox($MB_ICONERROR, "Error", "No folder selected. Exiting.")
            Return
        EndIf
        ; ------------------------------------------------------
        ; Prompt the user to select the destination folder for the .edl file data
        Local $destMessage = "Select Destination folder for the .edl files..."
        Local $destFolder = FileSelectFolder($destMessage, "F:\Audio\Type_1")
        ; -----------------
        If @error Then
            MsgBox($MB_ICONERROR, "Error", "No destination folder selected. Exiting.")
            Return
        EndIf
        ; ------------------------------------------------------
        ; Store the list of .wav files from the selected source folder
        Local $wavFiles = _FileListToArray($sourceFolder, "*.wav", $FLTA_FILES)
        ; -----------------
        If @error Then
            MsgBox($MB_ICONERROR, "Error", "No .wav files found in the selected folder.")
            Return
        EndIf
        ; ------------------------------------------------------
        ; Specify the path to the master .edl file
        Local $masterEdlFile = "G:\Session_Master\Show\Session_Data\Type_1.edl" ;"G:\Session_Master\Show\Session_Data\Type_1.edl"
        ; -----------------
        If Not FileExists($masterEdlFile) Then
            MsgBox($MB_ICONERROR, "Error", "The Type_1.edl file was not found.")
            Return
        EndIf
        ; ------------------------------------------------------
        ; Process each of the .wav file data and create corresponding .edl data file
        For $i = 1 To $wavFiles[0]
            Local $wavFileName = $wavFiles[$i]
            Local $wavBaseName = StringTrimRight($wavFileName, 4) ; Remove the ".wav" extension
            ; -----------------
            ; Destination .edl file path for each .wav file
            Local $newEdlFile = $destFolder & "\" & $wavBaseName & ".edl"
            ; -----------------
            ; Copy the master .edl file and rename it for each .wav file
            FileCopy($masterEdlFile, $newEdlFile, $FC_OVERWRITE)
        Next
        ; -----------------
        MsgBox($MB_ICONINFORMATION, "Success", "All .edl files have been created successfully.")
        ; -----------------
    ElseIf $confirmCreate = 7 Then
        MsgBox($MB_ICONINFORMATION, "Cancelled", "Operation cancelled by the user.")
    EndIf
EndFunc   ;==>_CreateT1Data
; ------------------------------------------------------

 

Link to comment
Share on other sites

sorry, I didn't understand well.
I have never come across an .edl file before. However, I googled it and saw that it is a .txt file, e.g.:

TITLE: My_Edit_Decision_List
FCM: NON-DROP FRAME

001  AX       V     C        00:00:00:00 00:00:05:00  00:00:00:00 00:00:05:00
* FROM CLIP NAME:  Clip_01.mov

002  AX       V     C        00:00:05:00 00:00:10:00  00:00:05:00 00:00:10:00
* FROM CLIP NAME:  Clip_02.mov

I thought you used Nircmd to modify the original Type_1.edl to match the title and times to the .wav.

that's why I said:
show us Type_1.edl, a .wav file, and the .edl file that nircmd produces for the .wav file
and maybe even nircmd could be bypassed

Now the script is ok?

 

Edited by ioa747

I know that I know nothing

Link to comment
Share on other sites

ioa747,

You noted, "Now the script is ok? "...Yes it it! Thanks so much!

The .edl file I employ are derived from an application entitled, "Software Audio WorkShop"...or "SAW" for short.

From the SAWStudio User Manual, SAWStudio Fundamentals, SAWStudio Terminology:

"EDL: Edit Decision List.
An EDL stores all session related information including automation, mixer configuration, region data and soundfile link information. An EDL does not store the actual soundfile data.
"

Hope this helps?

 

Edited by mr-es335
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...