Find and sort all files in folder without invisible files

Hi all,
I am trying to check whether the newest file added to a folder is an HTML file. In theory the folder should be empty when a new file is added because the script will delete all files in the folder just before it finishes running.
However, I am having a problem with .DS_Store files being created automatically in the folder. When Finder accesses the folder it creates a new .DS_Store file and thus the newest file added to the folder is never an HTML file.
I believe that the command "without invisibles" could help me with this problem. However, I have not been able to implement this successfully. I would appreciate if someone could please point me in the right direction. Here is what I have so far.
tell application "Finder"
          set sortedFiles to reverse of (sort (files of thisFolder) by modification date) as alias list
          set newestFile to item 1 of sortedFiles
-- check if newestFile is an HTML file
-- read file and send contents to another application
end tell
Thanks for your help!
Message was edited by: dsbird

Errr...  A quick reality check is called for. If you make files visible to the finder then they are no longer invisible files, so ignoring invisible files won't help you one bit. your best bet is to do a manual check for a file that starts with a "." (which would normally be invisible):
tell application "Finder"
          set thisFolder to folder "Pictures" of home
          set sortedFiles to (sort (files of thisFolder) by modification date) as alias list
          set newestFile to last item of sortedFiles
          if name of newestFile starts with "." then
                    set newestFile to item -2 of sortedFiles
          end if
end tell

Similar Messages

  • My iPhoto often have difficulty in opening without the "repair". Maybe it's because I have almost 2000 pictures! When I initiate repair using Mac for a long time to find and sort faces .... Is it possible to turn off or avoid this feature?

    My iPhoto often have difficulty in opening without the "repair". Maybe it's because I have almost 2000 pictures! When I initiate repair using Mac for a long time to find and sort faces .... Is it possible to turn off or avoid this feature?

    This user has found a "hack" to turn off faces.  Several users have reported success with the method.  I can't comfirm the method as I've not used it.  Use at your own risk.
    lopezio
    Re: Iphoto 11 -How to turn off faces?
    Dec 30, 2013 9:06 AM (in response to mkmichaelmk)
    Start of solution:
    I did some digging in the prefs of iPhoto and found out the following. This is how you can disable (turn off) Face detection, without deleting faces found so far (just in case you want to restart processing at another time):
    1. Quit iPhoto
    2. Open Terminal Application (Applications/Utilities/Terminal.app)
    3. Type the following (exactly as is):
    defaults write com.apple.iPhoto PKFaceDetectionEnabled 0
    (then return)
    4. - Start iPhoto - Faces stops getting on your nerves...
    If you ever need to re-enable faces, just do the same again and replace the 0 with 1.
    OT

  • On my MacBook with Lion Safari does start, does not react immediately after trying to open it. Installing a new Safari does not help. Removing parts of Safari in the Library did not help. Where can I find and remove all components (LastSession ...)?

    How can I reset Safari with all components? On my MacBook with Lion, Safari does not start, does not react immediately after trying to open it. Installing a new Safari does not help. Removing parts of Safari in the Library does not help. Where can I find and remove all components as LastSession and TopSites?

    The only way to reinstall Safari on a Mac running v10.7 Lion is to restore OS X using OS X Recovery
    Instead of restoring OS X in order to reinstall Safari, try troubleshooting extensions.
    From the Safari menu bar click Safari > Preferences then select the Extensions tab. Turn that OFF, quit and relaunch Safari to test.
    If that helped, turn one extension on then quit and relaunch Safari to test until you find the incompatible extension then click uninstall.
    If it's not an extensions issue, try troubleshooting third party plug-ins.
    Back to Safari > Preferences. This time select the Security tab. Deselect:  Allow plug-ins. Quit and relaunch Safari to test.
    If that made a difference, instructions for troubleshooting plugins here.
    If it's not an extension or plug-in issue, delete the cache.
    Open a Finder window. From the Finder menu bar click Go > Go to Folder
    Type or copy paste the following
    ~/Library/Caches/com.apple.Safari/Cache.db
    Click Go then move the Cache.db file to the Trash.
    Quit and relaunch Safari to test.

  • Using applescript for Find and Replace All in Pages 2.0

    i saw that Pages 2.0 is scriptable
    i try to create a script for merge use to find and replace all occurence of a certain string using a script but Pages doesn't seems to respond to "Find" even using "System Events"
    how can i do to use this function with a script
    Thanx for any help
    S.B.
    ibook G3   Mac OS X (10.4.6)  

    OK, here's another example. This one gets the text as a string and uses the offset property to find "[", presuming it to be a merge delimiter. (Pages' text doesn't support "offset of").
    One failing of this scheme is that the offsets are incorrect if you have inline objects (pictures, shapes, tables, etc.). While it is probably possible to compensate for them, that's a trickier proposition.
    <PRE>-- Example merge replacements:
    property mergeText : {"[name]", "John Smith", "[address]", "1234 Anystreet"}
    on lookup(mergeWord)
    set theCount to count of mergeText
    repeat with x from 1 to theCount by 2
    if item x of mergeText = mergeWord then
    return item (x + 1) of mergeText
    end if
    end repeat
    -- If merge field is not found, delete it (replace it with the empty string)
    return ""
    end lookup
    tell application "Pages"
    repeat
    tell body text of document 1
    -- Get text as a string so that "offset of" can be used.
    set allText to it as string
    set startOffset to offset of "[" in allText
    if (startOffset = 0) then
    exit repeat
    end if
    set endOffset to offset of "]" in allText
    select (text from character startOffset to character endOffset)
    end tell
    set mergeWord to contents of selection
    tell me to lookup(mergeWord)
    set replacement to result
    set selection to replacement
    if (replacement is "") then
    -- Get rid of extra whitespace (space or return)
    -- Do it in a "try" block to handle edge cases at start or end of text.
    try
    set theSel to (get selection)
    set ch1 to character before theSel
    set ch2 to character after theSel
    if ((ch1 is " " or ch1 is return) and (ch2 is " " or ch2 is return)) then
    select character after theSel
    delete selection
    end if
    end try
    end if
    end repeat
    end tell</PRE>
    Titanium PowerBook   Mac OS X (10.4.6)  

  • I do i find and replace all in numbers

    How do I find and replace all.  It is time-consuming to find and replace one entry at a time.

    Works here. As you can see, all three instances were located, in my test.
    Can you think af anything that could be different in your case than in my example?
    Jerry

  • My question is how can i find and redownload all my older apps ?

    HI,
    I have an Iphone 4, and bought mostly all of my Apps from my Iphone.
    I needed a certain App called Viber and tried to download it.
    I didn't work and it told me to download it from my computer (Macbook pro) Itunes,
    which i did, then i synched (my error) my iphone to my mac, then it erased all my apps from my iphone.
    My question is how can i find and redownload all my older apps ?
    Do i have to go find them manually and download them again?

    I'm guessing on the computer you connected to you were not logged into our account in iTunes and/or you never transferred your apps from your iPhone to your computer.
    Yes, you will need to download all of them again manually.

  • How to clear the cache files in folder Temporary Internet Files

    When one user opens files such as pdf. or doc. from Portal,  the same file will be downloaded into the Temporary Internet Files folder. if another user copied the files out of the Temporary Internet Files folder from this computer and save to someplace else, then we face one security problem.
    So my question is: How to clear the cache files in folder Temporary Internet Files??  Can we delete the files automatically when close the files in Portal??
    or is there some ways to make encrypty???
    Thanks very much!

    Hello,
    this is a basical security problem which should be resolved by the OS standard security setup . No other user should have access to the temporary file folders in the personal directory. The user account must be secure. Normaly your security problem should not be a problem if basic security exists on the clients.
    You can resolve this problem if every user has his own account on the client
    The users having no administration permissions on the clients
    The folder for the temporary internet files is placed in the personal profile folder of the user account.
    On default no other user has access rights to you personal folder, this means the client OS is setup correctly.
    You can setup the IE that no temporary files are saved (but it reduces performance)
    You can enable IE to delete automaticly the temporary files if IE is closed.
    Hope it helps.
    Regards
    Alex

  • How to find and export all Scheduled Tasks in Domain with multiple servers.

    Hi everyone,
    I have been given a task of finding all of Scheduled Tasks in the Domain on all of the servers. So far I have manage to create a script that will pull out all Scheduled Tasks from one Server, in this case Domain Controller. 
    Butt in my company are more than 150 servers so I am looking for a script that can connect to AD (or LDAP), than to certain OUs, then pull out Server list and than query them for Schedule Task. I have found already some scripts online and tried to adjust
    them butt they simply didnt work.
    I am new in the company and still learning about the system,  this is my first real task so any help will be greatly appreciated.

    Just a tip that I found after running across this myself - if you run a
    Get-AdComputer -filter {operatingsystem -like '*server*'} | ft name | out-file servers.txt
    and then save the output to a text file, it may look good, but there may be white space at the end of the computer names. Make sure that only the computernames are in the file and then the script works great.
    http://absoblogginlutely.net
    This would happen because you are trying to get around the format of the output.  When you want the raw value do it this way;  it is faster and easier:
    Get-AdComputer -filter {operatingsystem -like '*server*'} |
         %{$_.Name } | out-file servers.txt
    Now there can never be any extra spaces and there will be no header to cause problems. 
    This is why it pays to spend time studying the details of how PowerShell works instead of just sticking things together until you get a result.  PowerShell is designed to do all of these things without fudging or guesswork but it requires that you actually
    learn how it works.  I highly recommend stating with a good technical book on PowerShell.
    ¯\_(ツ)_/¯

  • IBook G4 slowdown with find and sort

    My wife's iBook frequently decides to slow down to a mere crawl, and it sounds like the hard drive (I think) is working steadily during these spells. Looking at the processes w/ top, find seems to be sucking up heaps of CPU time. I tried killing the find process, at which point sort and then makewhatis took over and continued beating on the machine. Any idea where these commands are issuing from and how to avoid them or at least reschedule them? (This often happens in the middle of the work day.) Perhaps this is a spotlight issue, since it started around the time we updated to 10.4. But I've noticed no such issues with my powerbook since updating to 10.4.
    Thanks for any suggestions.
    iBook G4   Mac OS X (10.4.4)  

    Errr...  A quick reality check is called for. If you make files visible to the finder then they are no longer invisible files, so ignoring invisible files won't help you one bit. your best bet is to do a manual check for a file that starts with a "." (which would normally be invisible):
    tell application "Finder"
              set thisFolder to folder "Pictures" of home
              set sortedFiles to (sort (files of thisFolder) by modification date) as alias list
              set newestFile to last item of sortedFiles
              if name of newestFile starts with "." then
                        set newestFile to item -2 of sortedFiles
              end if
    end tell

  • How to create a hyperlink to a onedrive file or folder without sharing it with anyone. (eg Create a hyperlink in Onenote to a file on my own Onedrive, for only me to use !)

    Hi All.
    When I view a file in Word online the URL displayed is:
    https://onedrive.live.com/view.aspx?cid=53B31F7A44698440&resid=53B31F7A44698440%2130033&app=Word
    Say I want to insert a link to the file in a website or OneNote page, such that it has NOT been shared with anyone.  ie Only I have permissions to view it like the file reference by the above link.
    Can I simply use the above URL as a link?
    I have used Ondrive sharing, but I think all the methods given result in the file being shared with other named people or publically.  eg like this one: http://1drv.ms/1zOli6p
    ...which when viewed in word online shows this URL:
    https://onedrive.live.com/view.aspx?cid=53B31F7A44698440&resid=53B31F7A44698440%2130035&app=Word
    I have been experimenting and it seems to work.  However, if the above does work, what I don't get is why OneNote does not allow a link to be created to a file stored on Ondrive. (On my PC it sonly seems to allow links to locally stored files).
    I have used GoogleDrive which allows you to select a  file and right click it to "receive a link" which you can use in the manner described above.  This is a really useful feature.
    Note that in a similar way, I would like to create a link that causes onedrive to open and display a chosen folder.  This seems to work ok when I use a URL this one that only I have permissions to view:
    https://onedrive.live.com/?cid=53B31F7A44698440&id=53B31F7A44698440%2130031 
    Any advise is really appreciated.
    Harvey

    Hi,
    >> Can I simply use the above URL as a link?
    Yes, the link above should work.
    >>Only I have permissions to view it like the file reference by the above link
    You can refer to this link to set permissions when sharing files and folders.
    Share files and folders and change permissions
    By the way, this forum is for discuss questions about Office Development. For OneDrive questions, you can refer to OneDrive forum to get more help, so more professional members will be involved. Thanks for your understanding.
    OneDrive Development Forum:
    https://social.msdn.microsoft.com/Forums/onedrive/en-US/home
    Best Regards
    Lan
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • For some reason, my compression option is grayed out under "File" menu, and when I select a folder with multiple files, or multiple documents, and try to right-click or tap the mousepad with two fingers, I do not get a "compress" option available. Help.

    I don't know why, but when I select a folder with multiple docs contained within it, or multiple files, the Compress option is grayed out under the File menu, nor is it available when I right-click. Please help.

    Yes it is, but I have the same problem of the option does not appear with "right click" (I'm actually control-clicking), and COMPRESS is grayed out under the file menu. I'd like to fix it.
    Hmm. After finding the Archive Utility,* I tried archiving the folder. It came out as .cpgz, ugh. Found there was a preference to make .zip the default. It worked!
    And now…the menus are not grayed out. ?!?! OK.'
    Hope this helps someone.
    *You cannot find this via search, apparently it is a hidden file, you have to click from the root drive through to /System/Library/CoreServices (Thanks for the file path Alberto!)

  • Add text layer to all files in folder: what about files that already are searchable?

    Hi everyone
    I'd like to make my scanned PDF documents searchable using the OCR feature of Adobe Acrobat X Standard. The scanned PDF files are stored in one folder (or its subfolders respectively). In principle I could just go to the OCR feature, tell it to add that folder to the OCR conversion list and replace all PDF files in it with searchable versions.
    Some of the files in the folder, however, already are searchable because they were created from Word files for instance. My question is: What will Acrobat's OCR feature do with these files that already are searchable? Will it leave them unchangend? Or will it create new files and replace their existing "text layer" with a new text layer?
    One of the reasons for my question is, that the existing "text layer" is free of recognition errors by definition (because it has been added by Word's conversion feature). This means, a new text layer added by Acrobat's OCR feature can only be equal or inferior in quality compared to the existing one. In the latter case, it wouldn't make sense to replace the existing "text layer".
    A second reason is that some of the already searchable files have security properties (i. e. signatures). What is going to happen to them when the OCR feature creates a new file?
    Thank you for your answers!

    The usual thing is that Acrobat will object, saying the file contains "renderable text", and do nothing.
    OCR on a file with signatures will, at best, invalidate the signature. More likely, all trace of the signature will be deleted, and it will attempt to do OCR on the visual appearance, finally leaving a graphic. OCR is  not really intended as a late-stage process.

  • How do I find and delete the pictures/videos folder on my iMac so I can repopulate it?

    Heading says it all

    In response to #6,7 and 8.
    Earlier, when I mentioned that I had duplicates in iPhoto, its because I was seeing 2 copies of the same pictures and sometimes 3...I wasn't sure why but I suspect that over the past few years I must have been doing something that copied some/many pictures to another location and iphoto had 2 copies to show me...I think I've resolved that with the apple tech guy because we merged everything into 1 single folder on my external harddrive. We then repopulated iPhoto...so everything looks good now...but I haven't gone through every single picture yet...but like I said, I suspect its ok now...no duplicates.
    However! I think I understand what YOU were referring to as duplicates. I think you meant having 2 databases of all my pictures...is that correct? In that case, I can definitely see the problem with that. I don't have 20,000 pictures like I'm sure some people have...its more like 1,500. However, lets assume that was 100 gigs of info. Well, then (again if I understand correctly), Organizer doesn't actually share the pictures from iPhoto...it can't as you said. So it pulls copies of the pictures and makes its own database. That would obviously double the amount of space the pictures were using up. So in this case, I would have 100gigs for iPhoto and 100 gigs for Organizer. Is this correct???
    I think I also understand why Organizer and iPhoto needs their own library of photos...its for the editing reasons...right? So if all my pictures reside in an iPhoto library, then in order for me to use Organizer, I would HAVE to import the pictures from iPhoto so that I would be able to use Organizer...to EDIT the photos...correct?
    Ok, If you say yes to both those questions...then that's a relief lol.
    In that case, I have to say that so far...I DO prefer the way iPhoto works with importing and organizing the photos. It also manages (if I'm not mistaken here) the movie clips I record with my iPhone and iPad. I still haven't used PSE to any great extent because I've been trying to learn and understand all this photo/video media management first.
    My wife and I are thinking of buying a really good DSLR camera. We've never had a really good camera but we were recently on a trip and one of our friends had some expensive ($4,000) camera and took some pictures of us. He is also a passionate hobiest of picture taking...so he's taken courses and as such, is very good! He showed us the pictures he took and we were totally impressed!
    So now my wife and I have decided to invest in a really good camera. Our children are still young and we would love to have much better quality pictures. The one thing our friend suggested was to use Adobe...but I think he said he uses Lightroom?
    So at this point, I've been going back and forth comparing iPhoto and PSE's. The other thing is, the company we are planning on buying the camera from is Henry's camera's. They also offer courses on picture taking and photo editing (seperate courses). The software they use? PSE on iMacs.
    In the end, I just want to ensure that I'm not short changing myself in terms of using the most versatile photo editing software available. I'm sure there are even better software programs...but probably way to advanced for us...

  • When I erased the name of a file on Path Finder and left it just with the extension, the file simply disappeared...

    Nowhere to be found, or at least I don't know how to find it... I tried doing the same thing in the Finder and it won't let me do that, this message appears: (You can't use a name that begins with a ".", because these names are reserved for the system. Please choose another name.). I didn't do it on purpose, but now I want to know what happened to the files and can I get them back...
    Thank you.

    In affect you are creating a hidden file, by removing file name. You need to either turn on viewing hidden files in Finder, or use third party software for viewing hidden files.
    To see hidden files in Finder, open your terminal.app and copy and paste the following command:
    defaults write com.apple.finder AppleShowAllFiles TRUE ;killall Finder
    and enter (return) then quit terminal.
    to revert back change true to false, as below:
    defaults write com.apple.finder AppleShowAllFiles FALSE ;killall Finder

  • I am a 66 year old novice. How can I find and print all the functions of the cmd key, please.

    How can I find and print out all the functions of a command cmd key please?

    You can also  go to MAC HELP and enter 'Key Board Shortcuts' in the entry field.
    Ciao.

Maybe you are looking for

  • ITunes will not open, no error, no dialog box, nothing

    iTunes plain and simply won't open... I get a little hour glass and then nothing. Other programs work fine. I've tried running the .exe directly, I've repaired, I've reinstalled, still nothing... is it something with the new version or what?!! Someon

  • How to check syntax errors in ABAP Queries

    HI Guys, How to check syntax errors in ABAP queries, Can please provide the T-Codes. Advande thanks to everybody. Thanks, Gourisankar

  • How to know which session id has acquired an object ?

    Hello, We work on database 11.2.0.2 and aw 10G style. concurrent users attach an aw in multi mode. They make update on cubes and on dimensions. They use the olap command Acquire before update changes. When an object cannot be acquired, i would like t

  • Adobe Prof 7 problems with Windows 7 - 64 bit

    My laptop crashed and I just purchased a new comptuer with Windows 7 - 64 bit.  Now have 2 problems with Adobe: #1 When I right click on a web site to save as PDF, it won't work. There is no error, no response.  Just doesn't do anything #2 If I go to

  • How do I tell Mail that it has incorrectly grouped messages as a conversation?

    I like the Conversations feature of Mail, but apparently using the same subject line in 2 emails sent 6 months apart is enough to have the grouped. Can someone please tell me how I can tell Mail that it's wrong and not to group those particular messa