Quantcast
Channel: Indigo Rose Software Forums - Forums
Viewing all articles
Browse latest Browse all 2105

search folder on all the drives

$
0
0
Hello, everyone. I have just learned how to use autoplay media studio. I have encountered some problems. I hope someone can give some guidance. Any suggestions are welcome. Thank you in advance

I wanted to search folder ABC on all the drives on my computer. I found the following two pieces of code, but I didn't know how to merge them to achieve my goal,




Find the ABC folder under drive C:\

Code:
-- Set the callback function (used by action Folder.Find)
function FindCallBack(CurrentFolder)
-- Show the cancel button
StatusDlg.ShowCancelButton(true, "Cancel");
-- Set the status dialog title, message, and status text
StatusDlg.SetTitle("Searching . . . ");
StatusDlg.SetMessage("Please wait. Search is in progress.");
StatusDlg.SetStatusText("Current Folder: " .. CurrentFolder);
-- Check if the user pressed cancel
cancel = StatusDlg.IsCancelled();
if cancel then
-- Cancel was pressed, stop the current operation
return false;
else
-- Cancel was not pressed, continue
return true;
end
end

-- Set the drive to search
drive = "C:\\";
-- Set the folder to search for
folder = "abc";
-- Search the specified drive for folders named "windows"
-- Display the status dialog
StatusDlg.Show(0, false);
search_results = Folder.Find(drive, folder, true, FindCallBack);
--Check to see if an error occurred during the search. If it did, display the error message.
error = Application.GetLastError();
StatusDlg.Hide();
if error ~= 0 then
Dialog.Message("Error",_tblErrorMessages[error]);
else
-- If no directories were found, inform the user
if (search_results == nil) then
Dialog.Message("Notice", "There are no folders named '" .. folder .. "' on drive '" .. drive .. "'.");
-- If folders were found, display a dialog containing a list of their locations.
else
message = "A folder named '" .. folder .. "' was found at the following location(s):\r\n\r\n";
for index, path in pairs(search_results) do
message = String.Concat(message, path.."\r\n");
end
Dialog.Message("File Search Results", message, MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
end
end

Gets all of the drive letters on the user's system and stores them in a numerically indexed table of drive letters called "drives".

Code:
-- Get a list of the available drives.
drives = Drive.Enumerate();

-- Determine if an error occurred.
error = Application.GetLastError();

-- If an error occurred, display the error message.
-- If no error occurred, display the available drives in a dialog.
if (error ~= 0) then
    Dialog.Message("Error", _tblErrorMessages[error], MB_OK, MB_ICONEXCLAMATION, MB_DEFBUTTON1);
else

    -- Create a string consisting of all of the drive letters and display them.
    all_drives = Table.Concat(drives, "\r\n");
    Dialog.Message("Notice", "Below is a list of all of your current drives:\r\n"..all_drives);
end

Viewing all articles
Browse latest Browse all 2105

Trending Articles