Now I try to make an AHK script which gets a list of file names
and adds a fixed ADS stream named Tag to each file from the list.
Basically the logic works but the FileAppend function doesn't write the ADS Tag.
It works using a hard-coded FileAppend like
FileAppend, "data", full_pathname:Tag
Here is the script, which contains messages to show what's going on.
The final parameters look like there is some strange character and makes the :Tag into a new line.
Code: Select all
; Read a file list and add ADS Tag to each file
; Check if the file list parameter is provided
if (1 > 0) {
; Get the file name from the command line parameter
fileListPath := A_Args[1]
} else {
MsgBox, 0, Error, No file list name provided.
ExitApp
}
; Check if the file list exists
if (!FileExist(fileListPath)) {
MsgBox, 0, Error, The file list does not exist: %fileListPath%
ExitApp
}
; Open the file for reading
FileRead, fileContents, %fileListPath%
; Split the file contents into an array of lines
fileArray := StrSplit(fileContents, "`n")
; Loop through each line in the array
Loop, % fileArray.MaxIndex()
{
filePath := fileArray[A_Index]
; Remove any leading or trailing whitespace (including line breaks)
filePath := Trim(filePath)
; Skip empty lines
if (filePath = "")
continue
; Perform an action with the file path
MsgBox, 0, File Path, %filePath%
; Define the ADS name
ADSName = %filePath%:Tag
ADSName := Trim(ADSName)
; Define the data to be written to the ADS
Data := "test1"
; Append the data to the ADS
MsgBox, 0, Parameters,%Data% %ADSName%
FileAppend, %Data%, %ADSName%
MsgBox, 0, Error level, %ErrorLevel%
}
; Exit the script after processing the list
ExitApp
XYplorer Beta Club