Spolight result and Applescript in harmony

Hello,
I'm new to Applescript and what I'm interested in doing seems like a great job for it.
I've made a spotlight search on a single folder in the file system and saved the search to its default location (/Users/alex/Library/Saved Searches/searchQuery). My search was for all pdf files in and beneath its directory. My list of results contain many duplicates and I'd like to thin it so that it shows or selects only unique files (this means if there are duplicates, show only one copy).
I was thinking that if I iterate through the list of results by comparing the name of the file with subsequent files along with its file size this should give me the result I'm looking for. Also, some of the duplicate files appear like abc-1.pdf or abc-2.pdf where these dash integers ("-1") is appended before the prefix so not to overwrite a file of the same name when I first downloaded them.
Finally, I'd like to make a copy of these files so that all are unique in a new directory. I plan on making a backup of these documents.
As an aside, I've already made the search and selected what I consider to be unique files by using simple mouse clicks while holding the command key. It's a painful thing to do when you have hundreds of these files. Even worse, I found out you can't copy files from a Spotlight search result - it gives you a system beep error.
Thanks to all who spend the time reading this lengthy thread. I appreciate your time and energy
Cheers,
Alex

Yes, you're right @Camelot. I had anticipated comparing file sizes along with the file name to check for duplicates. My file count that I want to sift through is in the hundreds and not thousands so I think this is sufficient for my purposes.
I've heard that calling a bash script from applescript to check for file details can be slow and was curious to know if you can run a regex comparison of the file name from applescript and also check the file size within applescript as well. Again, I guess since I have only a few hundred files to compare with, this slow down may be negligible and not worth the hassle of maybe doing it all within applescript.
What I have so far looks like:
(* Get array of paths to selected folders in following try statement *)
set pathsList to {}
try
set pathsList to ¬
choose folder with prompt ¬
"Select as many folders as you like:" with multiple selections allowed
on error eStr number eNum partial result rList from badObj to expectedType
do shell script "echo " & eStr
end try
(* The above method uses the colon (:) as a delimiter for subsequent folders. I'd like to get paths like /Users/alex/fileA:/Users/alex/fileB and so on... *)
(* Failing the above, I don't mind removing the "with multiple selections allowed" portion to get one path from the user instead. *)
(* Next I want to perform a spotlight search for files of pdf type within each path *)
set resultsList to {}
repeat with currentPath in pathsList
(* do Spotlight Search here *)
(* How do I retain the list of results in resultsList? *)
end repeat
set listOfNames to {}
set uniqueFilesList to {}
tell application "Finder"
repeat with currentFile in resultsList
set currentFileName to (the name of currentFile)
(* And do the same for the file size: *)
set currentFileSize to (the size of currentFile)
(* Make certain that the currentFile is an original and store in uniqueFilesList if so *)
set flag to 0
repeat with uniqueFile in uniqueFilesList
set uniqueFileName to (the name of uniqueFile)
set uniqueFileSize to (the size of uniqueFile)
if uniqueFileName contains currentFileName then
set flag to 1
if uniqueFileSize is not equal to currentFileSize then
set flag to 0
end if
end if
if flag = 1 then
break
end if
end repeat
if flag = 0 then (* add to final list *)
copy currentFolderName to the end of listOfNames
end if
set lastFolderName to currentFolderName
end repeat
end tell
Any fixes you may think of for this piece of code would be appreciated.
Regards,
Alex

Similar Messages

  • See my code that no me error after complied but not give me pdf result and

    hi master
    sir i use this code for create the pdf
    ExternalContext econtext = getExternalContext();
    InputStream stream = econtext.getResourceAsStream(PREFIX);
    try {
    JRResultSetDataSource mcon = new JRResultSetDataSource(getSessionBean1().getChartofaccRowSet());
    JasperPrint jasperPrint = null;
    jasperPrint = JasperFillManager.fillReport(stream, null, mcon);
    JRExporter exporter = null;
    HttpServletResponse response = (HttpServletResponse)econtext.getResponse();
    FacesContext fcontext = FacesContext.getCurrentInstance();
    exporter = new JRPdfExporter();
    exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
    exporter.setParameter(JRExporterParameter.OUTPUT_STREAM,
    response.getOutputStream());
    exporter.exportReport();
    fcontext.responseComplete();
    } catch (Exception ex) {
    log(" Error Description" , ex);
    error("Error counting rows: " + ex.getMessage() );
    error("Error counting rows: " + ex ); }
    sir this code not give any error but also not create /display the pdf
    i try to find the where problem occurred i get textfiled and send some value after one by one line
    like is this
    first time try
    JRResultSetDataSource mcon = new JRResultSetDataSource(getSessionBean1().getChartofaccRowSet());
    textField2.setValue(PREFIX);
    is given me right result and show /WEB-INF/reports/mfa.jasper in textfield2
    second time
    jasperPrint = JasperFillManager.fillReport(stream, null, mcon);
              textField2.setValue(PREFIX);
    when i press button second time this time page not give me result in textfield2 and show blank it means
    only this line have error but what i could not foud out jasperPrint = JasperFillManager.fillReport(stream, null, mcon);
    use see my code and give me idea or solution of my problem
    thank�s
    aamir

    I found and easier way to do it and wrote it up here: http://developers.sun.com/jscreator/learning/tutorials/2/reports.html

  • I am using Lightroom 5 and am hapy about it, but recently I hav encountered a problem when trying to edit an image in another program, i.e. Elements. I used the clone tool, saved the result and went back to Lightroom to open the image there. I did find a

    I am using Lightroom 5 and am hapy about it, but recently I hav encountered a problem when trying to edit an image in another program, i.e. Elements. I used the clone tool, saved the result and went back to Lightroom to open the image there. I did find a second copy, but this is identic with the one I already had in Lightroom, and I can see noe result of the clone process.

    At the moment I would say it is uncertain whether Acrobat is completely ignoring the change, or whether the changes you are making aren't affecting the ink density. I have a suggestion for a test you could make to see which is the case.
    When editing in Photoshop just add a box or mark on the image, for your tests.
    - If this box does not appear in Acrobat, you know Acrobat is not seeing the edit
    - If this box does appear in Acrobat, you know the problem is that your tool for changing ink densities is not taking effect.

  • 2.1EA2: Pinning Query Results and changing Connections [fixed in 2.1.0]

    I am on 2.1EA2 (JDK 1.6.0_16) and been playing with the new SQL Worksheet pin query results functionality. I have found that it is possible to run a query against one connection, pin the results and then change connection and run the same (or a different) query against another connection. I really like this, but found a few problems:
    #1 There doesn't seem to be any way to tell which connection a query result tab was actually run against
    #2 Even if all rows are fetched, if I then disconnect from the first connection it can get quite messy. Sometimes I get an empty connection dialog (I can't remember the exact title and it doesn't reproduce consistently) with only the close window X in the corner. Some times I get prompted to log in with a connection information dialog with no reference to the connection it is connecting to - cancelling only brings up the same dialog again until I successfully connect. Some times I get prompted to log in and while that is still on the screen, SQL Developer logs me back in to the connection (even though I don't save passwords) - I even get a new worksheet for the reconnected connection.
    theFurryOne

    Raghu,
    I am happy with both.
    #1 - I would be happy if the connection name was at the start of the tool-tip style pop-up when hovering over Query Results tab and the Query Result SQL dialog that opens on the SQL button. -K-'s suggestion makes it immediately obvious for the currently selected Query Results tab, without having to move the mouse or click on something.
    Ideally, I would like something similar for the other output tabs (ie Script Output), but they seem to show results for all connections that the worksheet has used, so the same concept may not work.
    #2 - I am used to the grid being cleared when disconnecting from earlier versions - I assumed that this was a bug where SQLD was not checking the connection of the results, just the current connection of the worksheet.
    theFurryOne

  • How to use stored procedure with many return results and variable with perl

    Hi everybody,
    i´m writtting now a Perl programm, wich use a oracle stored procedure with more than 1 result and 1 variable(I have to return 2 variable fpr each result). I don´t now how I can get it.I already search the web but I didn´t find.
    My example:
    PROCEDURE get_projects_and_sub_projects (
    v_project_id IN INTEGER,
    v_project_c_id OUT INTEGER,
    v_project_id_find OUT VARCHAR2
    IS
    BEGIN
    SELECT c_id, proj_id
    INTO
    v_project_c_id,
    v_project_id_find
    FROM t_projet
    WHERE t_projet .ksa_pro_art_kbz = 'KU'
    AND t_projet.proj_id LIKE v_project_id || '%';
    EXCEPTION
    WHEN NO_DATA_FOUND
    THEN
    v_project_c_id := NULL;
    v_project_id_find := NULL;
    WHEN OTHERS
    THEN
    kmessages.error (NULL,
    'get_projects_and_sub_projects',
    'Project-Name: ' || v_project_id,
    'Errornumber: '
    || SQLCODE
    || ' Error: '
    || SQLERRM,
    TRUE,
    TRUE
    raise_application_error (-20001,
    'Error '
    || SQLCODE
    || ' get_projects_and_sub_projects: '
    || SQLERRM,
    TRUE
    END get_projects_and_sub_projects;
    in Perl Program:
    sub get_projects_unterprojects_name($$){
    my ($db_handle, $proj_name_id) = @_; #$db_handle ist the DB Connection return value
    my $db_proj_c_id;
    my $db_proj_name;
    eval{ my $csr = $db_handle->prepare(q{
    BEGIN
    pro_doc_ber.get_projects_and_sub_projects(:proj_name_id, :db_proj_c_id, :db_proj_name);
    END;
    # parameter value
    $csr->bind_param(":proj_name_id", $proj_name_id);
    # return values
    $csr->bind_param_inout(":db_proj_c_id", \$db_proj_c_id, 11);
    $csr->bind_param_inout(":db_proj_name", \$db_proj_name, 20);
    $csr->execute(); };
    But this didn´t work. Could somebody give me some idea?
    Thank you
    Felx

    Some additional info would probably be helpful.
    What is your programming enviironment? Java?
    In any case I suspect that you will need to use the OCI to deal with specific Oracle types such as user defined object types -- thats not standard ANSI SQL.
    In Java I believe you need to use OPAQUE, there are some examples out there. I'm mostly a PL/SQL developer with some Java expereince so others here are more qualifed to answer your question more directly.

  • How can I reduce the width between search results and the preview fly-out?

    Hello, I am using a custom masterpage that reduces the overall width of page content but I am seeing an issue with my enterprise search site. The search results look fine but there is a large horizontal gap between the results and document preview window
    (when mousing over a word/excel/powerpoint result). This means that the preview fly-out is hardly visible unless the user scrolls horizontally to the right. Can someone tell me how to set a reduced width between the results web part and the preview window?
    Example:

    I think the issue is with the Callout orientation, have you customized the page and if so then you can customize the callout.
    check "beakOrientation" and you can set values like topBottom, leftRight as per your requirement.
    see here for more information -
    http://msdn.microsoft.com/en-us/library/office/dn135236(v=office.15).aspx
    Hope this helps!
    Ram - SharePoint Architect
    Blog - SharePointDeveloper.in
    Please vote or mark your question answered, if my reply helps you

  • Calculated key figures, results and grouping!!

    Hi,
    I'm working on a workbook with several sheets, the first of them contains the detail and also several result lines (Discipline, material group and material), the second one has a resume (Discipline and material group), etc.
    In the first and second sheet  I have a calculated key figure, but the result has a problem because I don't want to formulate it on the result, instead I need the summarization (total of  amounts by material), this problem is already solved by changing the calculate result as summation. But now I'm facing a new problem, when I try to see the resume report (2nd sheet) by material group I don't need the Calculated Key Figure, what I need are the summation and total result showed on the first sheet.
    One option I've been thinking of is to show the query on the first screen and hide the detail lines and just show the result and the summation lines; is this option ok? Do you have any other ideas?..
    Thank you very much for all the help you can bring me,
    Waiting for yours answers!!

    Hi,
    The best way to show only the summation by refering through cells. I mean the second option would be best.
    Message was edited by: AVR - IGA

  • Query not fetching results and shows executing

    All,
    When I run a query from SQL Plus I am getting query results immediately table with more than 50,000 rows), but when I run from TOAD or PL/SQL Developer am not getting any result and all I see is query executing no error message also.
    Surprising part is I am able to see results if the table is less than 100 rows in SQL Plus, TOAD and PL/SQL Developer.
    Please tell me is there anything I have to do in the database configuration, I am facing this issue due to database move to a new server.
    Thanks in advance

    Anand,
    I don't see this as an issue with TOAD or PL/SQL Developer, the reason is using my TOAD or PL/SQL Developer I am able to connect to the copy of this database (DEV) and able to fetch results. Only in the database I migrated to the new server I am not able to fetch results from connecting through any application, the only place I am able to run and get results is SQL PLUS.
    So I believe this is something which I am missing in my database configuration or in my new server.
    Please help me
    Thanks in Advance

  • How to get  the Overall result and Avg in Query

    Hi
    I am facing a problem to find Overall result and Avg for the keyfigure.
    Here is the scenario.
    I have a fiscalperiod ,qty in query column and material in row, when user enters the fiscalperiod(004.2006 to 006.2006)
    the output should come as
       0406 0506 0606  Avg
    M1  10  20   40     35
    M2  20  40   30     45
    res 30  60  70
    i can able to get the overall result not avg,
    if i change the properities of keyfigure 'Calicuate Result as 'Average of all values'',then i am loosing the overall result.
    eitherway i can able to get one result,not both.
    anybody can help.
    Thanks
    Madhu

    You have 2 key figures and you have put Material in the ROWS.
    Remove Material from ROWS and instead use 0FISCYEAR in the row selection.
    You can create 12 Key figures for each month and use either Filer or Free Characteristic using 0CALMONTH to restrict the month for the selection Variable.
    For the Key Figures use "Calculate Single Value as" Average.
    Create another formula as KF1KF2....+KF12 to get the sum of average.
    Regs
    Gopi
    Assign points if it helps...

  • Result and league table

    I need to set up a fixture list/ results and linked league table in Numbers. I know it is possible in excel and open office, but I want to stay Apple friendly. I have tried to import the excel spreadsheet and Numbers 09 states it can not open it. Are there any templates, for (to all intents and purposes) a soccer league ?
    Please help, thanks

    Which is the exact format of the Excel spreadsheet ?
    Is it a way to get it ?
    Yvan KOENIG (VALLAURIS, France.) mardi 18 août 2009 15:00:28

  • Google search does not work. It does not bring back any results and disables my internet connection until I close the brower, wait, and then open it again.

    Google search does not work. It does not bring back any results and disables my internet connection. I have to close the browser, wait, and then open it again. It only seems to happen when I am signed into my Google account. If I am signed out the search functions properly.

    Do a malware check with some malware scanning programs on the Windows computer.<br />
    You need to scan with all programs because each program detects different malware.<br />
    Make sure that you update each program to get the latest version of their databases before doing a scan.<br /><br />
    *http://www.malwarebytes.org/mbam.php - Malwarebytes' Anti-Malware
    *http://www.superantispyware.com/ - SuperAntispyware
    *http://www.microsoft.com/security/scanner/en-us/default.aspx - Microsoft Safety Scanner
    *http://www.microsoft.com/windows/products/winfamily/defender/default.mspx - Windows Defender: Home Page
    *http://www.safer-networking.org/en/index.html - Spybot Search & Destroy
    *http://www.lavasoft.com/products/ad_aware_free.php - Ad-Aware Free
    See also:
    *"Spyware on Windows": http://kb.mozillazine.org/Popups_not_blocked

  • Activate or skip "Record Results" and "Step Failure Cause Sequence Failure" for all steps of a step type

    Hello all,
    I am using teststand 3.1
    Is it possible to skip or activate ´"Record Results" and "Step Failure Cause Sequence Failure" for all steps of a step type.
    It is very much work to do this for all steps, because I have hundred of steps
    regards
    samuel

    hi,
    here is an example that will change the TS.NoResult. You just have to change this area of the sequence to suit your needs
    I haven't added any fancy stuff, such as adding a filedialog to get the seq file to change, you will find the various variables in the Locals.
    Hope it helps
    There is a version for 3.1 and 3.5.
    Regards
    Ray Farmer
    Regards
    Ray Farmer
    Attachments:
    ChangeStepTypeRunMode.zip ‏30 KB

  • Modifying the text "Result" and "Overall Result" in a BEx query output

    Hi,
    1) Is it possible to modify the text "Result", "Overall Result" which appears in the sub-total and grand total lines of BEx query output? I do not see any related setting the properties area of the object in BEx Query designer. Do I have to write some VB code or can I do something in Customer Exits?
    Also my client wants that this text need to be made dynamic such as "Sub-Total for the month of Jan 2006".
    I can use work book option and change the texts manually.But this is not meeting my clients requirement.
    2)Is it possible to have dynamic title text for a BEx query?
    We are on BW 3.5 & if any of you could provide / guidance to the above issue.
    Thanks,
    Venkatram

    You will have to use VB Macros to change the text "Result" and "Overall Result", there is not settings in the query designer for the same.
    You can have dynamic descriptions for queries using text variables like Expense Query for month of Jan 2006, if user selected Jan 2006.
    Thanks.

  • Am having intermittent difficulty rendering in FCE. Using the Sequence menu sometimes delivers results and Command R fails every time. Most frustrating. Any thoughts from anyone? Thanks.

    Am having intermittent difficulty rendering in FCE. Using the Sequence menu sometimes delivers results and Command R fails every time. Most frustrating. Any thoughts from anyone? Thanks.

    Michael,
    There is a forum for Final Cut Express I'd recommend re-posting there.
    Roger

  • Learning Unix and AppleScript on Lion

    Hi everyone,
    I want to learn Unix on OS X Lion and AppleScripts very well. I've been a Mac user since Tiger OS X, but now I've decided to be serious about Unix and AppleScript. Can anybody recommend good books for this purpose. I would like to have books which start from basics but later go on to great details to fully explore these two things. I really need expert opinion here, plz.
    Best,
    Naveen

    If you already know something about unix commands, there is a scripting tutorial at http://www.tldp.org/LDP/abs/html/index.html
    If you need a tutorial on unix commands, http://osxfaq.com/Tutorials/LearningCenter/UnixTutorials/LoseTheMouse/index.ws had a pretty good tutorial, although at the moment, that link isn't loading for me now so I don't know if it is still up online or not.
    for creating logout hooks, http://www.bombich.com/mactips/loginhooks.html might help.
    Also, in Terminal, type man launchd.plist if you can think of a scenario where you could implement a "cron-like" solution. Then refer to Apple's own periodic daily/weekly/monthly launchd plists (com.apple.periodic-*ly.plist) at/System/Library/LaunchDaemons/. There are more triggers available than just day/date/time, such as "watchPaths" and "RunAtLoad." Home grown launchd plists ones should go in /Library/LaunchDaemons/ or Library/LaunchAgents, not /System/Library/LaunchDaemons/. Also man launchd (no ".plist").

Maybe you are looking for