How can i save the filesystem information

Hello,
I need your help.
How can i save additional the information from the filesystem
(e.g. filepath info C:\testfolder_a\testfolder_a12)

Thanks in advance

Is there nobody who can give me a hint.

Hi @LP16 I dont find it black and white when dealing with the file structure. I am on windows and getting the file information from another local server. It took me a while to get there. This script will get my directory and files with in the directory. I do not get the Exif data as it takes way to long to extract. This script also caches the names of the dir and files as well checks for last inserted dir and file so it will not try to import duplicate entries. I have also programmatically created compost key out of the fields to help eliminate double entry Another thing you will see in the script is remove apostrophes from the file names. Since the files were created from a different application we were not able to keep them from being upload with some special characters that other systems allow. Hope this helps

$directory = ‘\\server\files\Attach’;
$tempFile = $_SERVER[‘DOCUMENT_ROOT’] . ‘/processed_attached_files.txt’; // Save the file in the root directory of the host

// Check if the directory exists
if (is_dir($directory)) {
// Initialize an empty array to store processed files
$processedFiles = array();

// Load processed files from the temporary file
if (file_exists($tempFile) && is_readable($tempFile)) {
    $tempData = unserialize(file_get_contents($tempFile));
    if (is_array($tempData) && !empty($tempData)) {
        $processedFiles = $tempData;
    }
}

// Get the list of directories using glob
$directories = glob($directory . '/*', GLOB_ONLYDIR);

// Process directories
foreach ($directories as $dir) {
    // Extract directory name from the full path
    $dirName = basename($dir);

    // Get the list of files in the directory
    $files = glob($dir . '/*');

    // Process files
    foreach ($files as $file) {
        // Get the file name
        $fileName = basename($file);
        
        // Replace apostrophes with backslashes
        $fileName = str_replace("'", "''", $fileName);

        // Create composite key
        $compositeKey = $dirName . '_' . $fileName;

        // Check if the file has already been processed
        if (!in_array($compositeKey, $processedFiles)) {
            // Prepare the SQL query
            $sql_insert = "INSERT INTO dbo.qb_attach_txn (dir, file_name) VALUES ('$dirName', '$fileName')";
            
            // Execute macro sc_exec_sql
            sc_exec_sql($sql_insert);
            
            // Add the composite key to the list of processed files
            $processedFiles[] = $compositeKey;
        }
    }
}

// Save processed files to the temporary file in the host root directory after processing all directories and files
$result = file_put_contents($tempFile, serialize($processedFiles));
if ($result === false) {
    echo "Failed to create or write to the temporary file.";
}

} else {
echo “The directory does not exist.”;
}