Extracting a file name from a folder...

Discussion in 'Mac Programming' started by Dogwalla, Jan 29, 2013.

  1. macrumors newbie

    Joined:
    Jan 29, 2013
    #1
    I built two scripts that work quite well for me. The first one deletes the contents of folders within our company network and uploads a new file. The second script runs around the network and verifies the file uploaded properly.

    The problem I'm having is this: I have to manually put in the file to be verified every time it runs.

    The folder the source file lives in never changes, the file name changes before every upload, but there is only one file in the directory. What I'm wondering is if there is a little chunk of code I can use to just extract the file name of whatever is living in that folder so I use it in my verification script? It really sucks eggs to hop into the code and change it manually so it can run on a nighttime schedule.

    I've tried everything I could find on similar examples, but I can't get anything to do what I need.

    Thanks in advance.
     
  2. macrumors 6502a

    ConCat

    Joined:
    Jul 27, 2012
    Location:
    In an ethereal plane of existence.
    #2
    I'll go ahead and assume you're using AppleScript. Here's the basic idea of how you'd do that:

    Code:
    tell application "Finder" to get files of folder (POSIX file "/Path/to/directory")
    or you could use the old-style Mac OS directory structure

    Code:
    tell application "Finder" to get files of folder "Path:To:Directory"
    Either one.
     
  3. thread starter macrumors newbie

    Joined:
    Jan 29, 2013
    #3
    Holy cow...that worked perfect. Why does it seem that all the easy stuff ends up being the hardest?
     

Share This Page