Extracting file name text

I have written a script that automatically sends out via FTP application Transmit, any new file that enters into a hot folder
what I need now is..
a script that writes information on a textedit document
I need
•open up a textedit document
then prints
•the file name "theFile"
•time and date
•then saves the file on the desktop
THEN when another file is sent, the script adds that the next file done info to the text file thus creating a list of completed tasks

File Name, Time, and Date format -
on adding folder items to this_folder after receiving these_items
-- Create or open, and edit, 'Folder_Contents.txt' on the 'Desktop'.
set FILE_REF to open for access file (((path to desktop folder from user domain) as string) & "Folder_Contents.txt") with write permission
repeat with i in these_items
tell application "Finder" to set file_Name to ((displayed name of i) as string)
-- Writes the string at the end of 'Folder_Contents.txt'. (File Name, Time, and Date format)
write (file_Name & " " & (do shell script ("date +%H.%M.%S' '%d.%m.%Y")) & return) to FILE_REF starting at eof
end repeat
close access FILE_REF -- Close 'Folder_Contents.txt'.
end adding folder items to
... or. Date, Time, and File Name format -
on adding folder items to this_folder after receiving these_items
-- Create or open, and edit, 'Folder_Contents.txt' on the 'Desktop'.
set FILE_REF to open for access file (((path to desktop folder from user domain) as string) & "Folder_Contents.txt") with write permission
repeat with i in these_items
tell application "Finder" to set file_Name to ((displayed name of i) as string) -- Extract file name from files' full path.
-- Writes the string at the end of 'Folder_Contents.txt'. (Date, Time, and File Name format)
write ((do shell script ("date +%d.%m.%Y' '%H.%M.%S")) & " " & file_Name & return) to FILE_REF starting at eof
end repeat
close access FILE_REF -- Close 'Folder_Contents.txt'.
end adding folder items to
  Mac OS X (10.4.4)  

Similar Messages

  • Can't Select/Edit File Name Text - they go blank

    Sometimes when I try to select a file name to edit it, the name disappears when I first click it. This often happens in list view. If I switch to icon view, most of the times, but not always, I can then select the file name text. Sometimes if I switch back to list view, then I can select the file name text as expected, but again not always.
    It is intermittent so I can't give any consistent info on how or when it happens.
    Thanks,
    Steven

    Try this. Select the file and hit the enter key. Does that highlight the name without deleting it? If so, adjust your mouse click settings and see if that fixes the problem. If not, create a new admin account, log into, and see if the problem's gone. Report back.

  • Extracting file name info

    if I have a files named as such...............AR123 Smith, John.mov
    I need to extract out just the initials AR from the name.
    my following code does not work, can anyone help, thanks.
    on open the_files
    set a_file to item 1 of the_files -- if I drag the above file onto my droplet
    tell application "Finder"
    display dialog a_file as string with title "0-File Name"
    set AppleScript's text item delimiters to {":"}
    set the_project to the last text item of a_file
    display dialog the_project as string with title "1-File Name" -- AR123 Smith, John
    set AppleScript's text item delimiters to {" "}
    set theprojectcode to text item 1 of the_project -- AR123
    display dialog theprojectcode with title "2-Project code" -- AR123
    repeat with a_character in theprojectcode
    if a_character is in the_alphabet then
    set theprodinitials to theprodinitials & a_character -- AR
    end if
    end repeat
    set theprodinitials to "- " & theprodinitials
    open theprodinitials
    display dialog theprodinitials with title "3-producers initials"
    end tell
    end open

    I am guessing that "the_alphabet" is defined at a global level elsewhere in your script, but I set it in the open handler here - the variable "theprodinitials" also needs to exist before using it in an expression, so I just set it to a blank "". I'm not sure what the open statement is supposed to open (it needs a complete file path), so I just set it (as a comment) to open the original file. Here is another approach that doesn't use text item delimiters:
    <pre style="
    font-family: Monaco, 'Courier New', Courier, monospace;
    font-size: 10px;
    margin: 0px;
    padding: 5px;
    border: 1px solid #000000;
    width: 720px;
    color: #000000;
    background-color: #FFDDFF;
    overflow: auto;"
    title="this text can be pasted into the Script Editor">
    on run
    open {(choose file)}
    end run
    on open the_files
    set the_alphabet to characters of "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
    set the_prod_initials to ""
    repeat with a_file in the_files
    display dialog a_file as string with title "0-File Name"
    tell application "Finder" to set the_project to the name of a_file
    display dialog the_project as string with title "1-File Name" -- AR123 Smith, John
    set the_project_code to the first word of the_project -- AR123
    display dialog the_project_code with title "2-Project code" -- AR123
    repeat with a_character in the_project_code
    if a_character is in the_alphabet then
    set the_prod_initials to the_prod_initials & a_character -- AR
    end if
    end repeat
    set the_prod_initials to "- " & the_prod_initials
    display dialog the_prod_initials with title "3-producers initials"
    -- tell application "Finder" to open file a_file
    end repeat
    end open</pre>

  • Extract file name for size gt 10M

    Hi
    I am writing a script to extract the file name whose size is greater than 10M. What I wrote is as follows:
    export LIST=`ls -ltr | awk '{print $5 ,$9}'`
    for SUBLIST in ${LIST}; do
    echo ${SUBLIST}
    export SUBLIST1A=`echo ${SUBLIST} | awk '{print $1}'`
    export SUBLIST1B=`echo ${SUBLIST} | awk '{print $2}'`
    echo ${SUBLIST1A}
    echo ${SUBLIST1B}
    ###### if [[ $SUBLIST1A -gt 10000000 ]]; then
    if ( '100000000' -gt '10000000' ); then
    #echo "KITCARSON File size \> 10M : $SUBLIST1B" | mailx -s "File Size Alert" $[email protected]
    echo "KITCARSON File size \> 10M : $SUBLIST1B" | mailx -s "File Size Alert" [email protected]
    fi
    done
    But this does not seem to be working. Can somebody help me with this.
    Any help would be appreciated.
    thanks

    you can use the find command to do the same thing..
    #find . -size +10000000c
    ./core.7.Z
    ./T111685-09.tar.Z
    ./eleven
    this will print out all files greater than 10MB in size.Check man pages for find.
    cheers
    -Dhruva

  • File extraction -File name is timestamped

    Hi Team,
    We are loading the data using flat file. The file will be stored in the application directory. we created a logical fiel name and it is  used in the data source.
    My problem is every day the file is uploaded to the applicaiton directory and the file name will be appended with time stamp
    for example
    file_01022011123445
    file_02022011042015
    I tried to handle this by creating an abap routine ,but i am unable to get the exact  file name since the timestamp field is dyanamic.I even tried to read the file names from the applicaiton directory using following function modules
    SUBST_GET_FILE_LIST
    F4_DXFILENAME
    FILE_GET_NAME
    But it didnot worked. Any suggestion will be appreciated.
    Thanks,
    Jim
    Edited by: Jim Jose on Feb 2, 2011 1:04 PM

    Hi,
    Your file naming convention seems to be "file_ddmmyyyyhhmmss". That means you already know the first 13 characters of the filename you need. ("file_" is constant, the next 8 characters come from sy-datum)
    The FM SUBST_GET_FILE_LIST accepts wildcards, so you could give the FILENM parameter as *. It would give you the names of all the files in the directory. After that, it is a matter of ignoring all the files which do NOT begin with those 13 characters. If you have one file being created in the directory for every day, this should work
    Regards,
    Suhas

  • Extracting File Name

    i am not a very good with coding but i have a I have a form
    with a type="file" field, which uploads the file to the server
    (using PHP).
    is there a way to "grab" the file name fom the end of the
    string and store it into a DB when the form gets submitted?
    I have been trying to find different ways of doing this for
    ages but without sucess.
    Cheers for any advice

    meesonator wrote:
    > i am not a very good with coding but i have a I have a
    form with a type="file"
    > field, which uploads the file to the server (using PHP).
    >
    > is there a way to "grab" the file name fom the end of
    the string and store it
    > into a DB when the form gets submitted?
    >
    > I have been trying to find different ways of doing this
    for ages but without
    > sucess.
    >
    > Cheers for any advice
    >
    Assuming you are using a 'Post" action on your file upload
    form, and the
    field name is "filename", and you are using PHP, try this:
    <?php echo $_POST["filename"]; ?>
    Harvey

  • Extracting file name from directory folder

    Hi,
    I need to loop a folder to retrieve out individual files.
    Is there any way to do it??
    Thank You!
    Michelle

    import java.io.File;
    File dir = new File("your directory name");
    File[] files = dir.listFiles();
    for (k=0; k < files.length; k++) {
      File currFile = files[k];
      do something
    }

  • Extracting file name from directory folder (~cont)

    what if I want to retrieve indiviual files of a certain file type...e.g. *.jsp file type, from a directory folder??

    You can implement a FileFilter, then use the listFiles method of the File class to return the related files:
    import java.io*;
    public class JspFileFilter implements FileFilter {
         public boolean accept(File pathname) {
              return (pathname.getName().endsWith(".jsp"));
         public static void main(String[] args) {
              File directory = new File("c:/web");
              File[] jspFiles = directory.listFiles(new JspFileFilter());
              for (int i=0;i<jspFiles.length;i++) {
                   System.out.println(jspFiles[ i ].getName());
    }

  • Importing in to iPhoto using file name date/time

    Hi
    +*I posted this originally in to iPhoto section but they suggest I submit here to see if anyone knows if there's an applescript. Thanks!*+
    I'm not too sure on how to exactly explain my problem but here goes...
    I have a mobile phone that does not save date/time taken data to the picture file when it takes photos. All of my previous phones/cameras have so this has never been a problem before. I Bluetooth photos and then add them to iPhoto '08.
    Problem is when they add they use the date/time added to create the event rather than the date/time taken. The picture filename displays date/time taken and I was wondering if there was a way to use the filename to have iPhoto adjust the metadata tag to the actual date/time taken? This would save me having to adjust time/date for each set of photos. The filename is for example P090308_12.00.jpg if taken on 09/03/08 at 12.00pm.
    I hope this is clear enough and that someone has some advice. Thanks for your help

    01. As per casdvm, download 'ExifTool-7.20.dmg' (872 KB in size), and install 'exiftool''.
    02. Try the provided starter code, editing it according to your needs ...
    --- Code starts here ---
    tell application "iPhoto"
    set tSelection to selection -- Obtain list of selected photos.
    repeat with i in tSelection
    try -- Capture any unexpected AppleScript error(s).
    set imagePath to (image path of i) -- Obtain full path of file.
    set imagePath to quoted form of imagePath -- Encase files' full path in single quote marks.
    set {oAStid, AppleScript's text item delimiters} to {AppleScript's text item delimiters, "/"}
    set imageName to last text item of imagePath as string -- Extract file name from files' full path.
    set AppleScript's text item delimiters to oAStid
    set imageName to get (characters 2 through ((count imageName) - 5) of imageName) as string -- Extract date and time values from file name.
    set tYear to (get (characters 5 through 6 of imageName) as string) -- Extract year from file name.
    if (tYear as number) > ((do shell script "date +%y") as number) then
    set tYear to ("19" & tYear) as string -- Append '19' before 'tYear'.
    else
    set tYear to ("20" & tYear) as string -- Append '20' before 'tYear'.
    end if
    set createDate to tYear & "." & (get (characters 3 through 4 of imageName) as string) & "." & (get (characters 1 through 2 of imageName) as string) & " " & (get (characters 8 through 9 of imageName) as string) & "." & (get (characters 11 through 12 of imageName) as string) & ".00"
    do shell script ("exiftool -DateTimeOriginal='" & createDate & "' -CreateDate='" & createDate & "' -overwriteoriginal_inplace " & imagePath) -- View 'exiftool -h' in 'Terminal'.
    end try
    end repeat
    end tell
    --- Code ends here ---

  • Add to iPhoto removes file name

    Apple Mail - It's great that we now have the return of the "Add to iPhoto" link for image attachments However, when using this function Mail renames the file as IMAGE, IMAGE-1, IMAGE-2 etc etc in the metadata.  This creates an issue where iPhoto is then unable to detect if any of the imports are already in the library, ie duplicates.
    A work around is to "Save" the images to a folder then using iPhoto "Add to Library" but this should not be necessary of course.
    I found this issue on both Macs in my home so presume it could be a wide spread issue?   Anyone have any experience of it.

    01. As per casdvm, download 'ExifTool-7.20.dmg' (872 KB in size), and install 'exiftool''.
    02. Try the provided starter code, editing it according to your needs ...
    --- Code starts here ---
    tell application "iPhoto"
    set tSelection to selection -- Obtain list of selected photos.
    repeat with i in tSelection
    try -- Capture any unexpected AppleScript error(s).
    set imagePath to (image path of i) -- Obtain full path of file.
    set imagePath to quoted form of imagePath -- Encase files' full path in single quote marks.
    set {oAStid, AppleScript's text item delimiters} to {AppleScript's text item delimiters, "/"}
    set imageName to last text item of imagePath as string -- Extract file name from files' full path.
    set AppleScript's text item delimiters to oAStid
    set imageName to get (characters 2 through ((count imageName) - 5) of imageName) as string -- Extract date and time values from file name.
    set tYear to (get (characters 5 through 6 of imageName) as string) -- Extract year from file name.
    if (tYear as number) > ((do shell script "date +%y") as number) then
    set tYear to ("19" & tYear) as string -- Append '19' before 'tYear'.
    else
    set tYear to ("20" & tYear) as string -- Append '20' before 'tYear'.
    end if
    set createDate to tYear & "." & (get (characters 3 through 4 of imageName) as string) & "." & (get (characters 1 through 2 of imageName) as string) & " " & (get (characters 8 through 9 of imageName) as string) & "." & (get (characters 11 through 12 of imageName) as string) & ".00"
    do shell script ("exiftool -DateTimeOriginal='" & createDate & "' -CreateDate='" & createDate & "' -overwriteoriginal_inplace " & imagePath) -- View 'exiftool -h' in 'Terminal'.
    end try
    end repeat
    end tell
    --- Code ends here ---

  • How to set selected file in FileChooser showSaveDialog to default file name

    Hi,
    How do I set selected file in JavaFX 2.0 FileChooser showSaveDialog, so I can prompt the user with a suggested default file name?
    I am converting a Java Swing application I wrote a few years ago to JavaFX 2.0.
    In the Swing application, I use setSelectedFile() as follows:
    JFileChooser jFileChooser = new JFileChooser();
    jFileChooser.setSelectedFile(new File(backupfile));
    jFileChooser.setCurrentDirectory(new File(outputDirectory));
    FileFilter filter = new FileNameExtensionFilter("Comma Delimited (*.csv)", "csv");
    jFileChooser.addChoosableFileFilter(filter);
    jFileChooser.setFileFilter(filter);
    filter = new FileNameExtensionFilter("XML Document (*.xml)", "xml");
    jFileChooser.addChoosableFileFilter(filter);
    jFileChooser.setAcceptAllFileFilterUsed(false);
    jFileChooser.setDialogTitle("Export File");
    int returnVal = jFileChooser.showDialog(jFrame, "Export");
    This would show a file chooser with the file name text field pre-populated with a default backup file name.
    I can't find an equivalent in JavaFX.
    Also, in the Swing application, I was able to determine which extension filter was selected at run time using getFileFilter().getDescription() as follows:
    String extension = jFileChooser.getFileFilter().getDescription();
    if (extension.equals("XML Document (*.xml)")) { ...
    I can't find an equivalent in JavaFX.
    Thanks,
    Barry

    You can use the open sequence file method on the application manager (then you only need to wire the file path)
    Rodéric L
    Certified LabVIEW Architect

  • Need help adding a default file name in a file chooser of save dialog type

    I need to create a file chooser with save dialog type, how can I add a highlighted default file name into the File Name textfield? As in Microsoft Word, when you want to save a document, a default file name Doc1.doc will appear in the File name text field of the file chooser even when you change to other directories.

    For JRE 1.4.0 you can use this fix:
    public class FileChooserFix implements PropertyChangeListener {
      private String fileName;
       * @see PropertyChangeListener
      public void propertyChange(PropertyChangeEvent ev) {
        JFileChooser chooser = (JFileChooser)ev.getSource();
        if (JFileChooser.FILES_ONLY == chooser.getFileSelectionMode()) {
          if (JFileChooser.SELECTED_FILE_CHANGED_PROPERTY.equals(ev.getPropertyName())) {
            File selectedFile = (File)ev.getNewValue();
            if (selectedFile != null) {
              // remember fileName of selected file
              fileName = selectedFile.getName();
          if (fileName != null &&
              JFileChooser.DIRECTORY_CHANGED_PROPERTY.equals(ev.getPropertyName())) {
            // reset selected file
            File directory = (File)ev.getNewValue();
            chooser.setSelectedFile(new File(directory, fileName));
       * Convenience method to create a fixed file chooser.
       * @return      fixed file chooser
      public static JFileChooser create() {
        JFileChooser chooser = new JFileChooser();
        chooser.addPropertyChangeListener(new FileChooserFix());
        return chooser;

  • The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.

    I've followed
    this blog post, but it didn't work for me. I truly don't want to change my solution path as this is not acceptable. What else can I do?
    I can't believe we still have limits on path length.

    Note that the solution described in the blog post does not change your solution path. The _CSRUN_STATE_DIRECTORY environment variable sets the location of the temporary folders used by the compute emulator. Your solution does not need to move.
    Though, you may still have problems related to path length inside your solution. To resolve these, I have sometimes used symbolic links (using MKLINK /D link target) or substed drives (SUBST X: path) to create shorter paths and then opened the
    solution from there. If I recall correctly, with the first method, you need to be careful how you navigate to the solution in the Open Project dialog. I think that if you browsed to the path, it would still use the long path, so you need to paste the short
    path into the file name text box to go directly to the location of your .sln file. I may be misremembering the details though.
    BTW, I can't believe we still have limits on path length either.

  • Extracting text from a file name on export / import (Regular Expressions??)

    I’m not even sure if the publishing service, File Naming, in Lightroom supports Regular Expressions or not?? Basically I’m trying to extract the left portion of the file name ie: everything before the underscore “_”. When I import a file I rename the file to reflect the current Image sequence number and then append the date the photo was taken; a typical file is as follows “05625_2008-01-05.dng” on export I would like the new name to be only the sequence number in this case “05625.jpg”. Ideally I would then like to append the folder name that contains the file… “05625 - FolderName.jpg.
    I don’t want to go down the road of figuring out the correct syntax if regular expressions aren’t supported. Thanks in advance - CES

    Is the imported sequence number captured in meta data somewhere or is their somewhere that all of the available fields and there reference names can be found???
    Unfortunately not anywhere available to the user (but it's still stored in at least some filed I know off).
    By the way, why did you choose to put the suffix at the beginning of the name (1234_2010-08-13.jpg)? The common practice is to leave the suffix at the end. That will ensure the filenames will sort in chronological order by filename and you could have easily used the suffix when exporting files. You wouldn't have this problem now.

  • Import From Folder: How to Extract the File Name in a Custom Column.

    Hello All
    Here´s what we´re trying to do:
    We have a folder with csv files named like this:
    Sales_2013-02-05.csv
    Sales_2013-02-04.csv
    Sales_2013-02-03.csv
    Sales_2013-02-02.csv
    Sales_2013-02-01.csv
    And in the csv files there are the sales columns but not the date column.
    So we want to extract the date from the file name.
    I´ve tried entering = Source[Name] in a custom column, but it adds a "LIST" link, and on a click on expand, it adds ALL file names from the folder in each row, instead of just the needed one.
    If we could get the proper file name in each row (from where they got extracted), we could split the column and get the date from there. But I don´t know how put the filename there properly.
    Can you help?

    This isn't entirely straightforward, but it's definitely possible. What you need to do is to apply all of your transforms to each individual file instead of the combined files. I do that as follows:
    1) Use Folder.Files as generated by the GUI to look at the list of my files.
    2) Pick one file and do all the transformations to it that I want to apply to all of the files. Sometimes, this just amounts to letting the autodetection figure out the column names and types.
    3) Go into the advanced editor and edit my code so that the transformations from step 2 are applied to all files. This involves creating a new function and then applying that function to the content in each row.
    4) Expand the tables created in step 3.
    As an example, I have some files with names that match the ones you suggested. After steps 1 + 2, my query looks like the following:
    let
        Source = Folder.Files("d:\testdata\files"),
        #"d:\testdata\files\_Sales_2013-02-01 csv" = Source{[#"Folder Path"="d:\testdata\files\",Name="Sales_2013-02-01.csv"]}[Content],
        #"Imported CSV" = Csv.Document(#"d:\testdata\files\_Sales_2013-02-01 csv",null,",",null,1252),
        #"First Row as Header" = Table.PromoteHeaders(#"Imported CSV"),
        #"Changed Type" = Table.TransformColumnTypes(#"First Row as Header",{{"One", Int64.Type}, {"Two", type text}, {"Three", type text}})
    in
        #"Changed Type"
    For step 3, I need to take steps 3-5 of my query and convert them into a function. As a check, I can apply that function to the same file that I chose in step 2. The result looks like this:
    let
        Source = Folder.Files("d:\testdata\files"),
        Loader = (file) =>
            let
                #"Imported CSV" = Csv.Document(file,null,",",null,1252),
                #"First Row as Header" = Table.PromoteHeaders(#"Imported CSV"),
                #"Changed Type" = Table.TransformColumnTypes(#"First Row as Header",{{"One", Int64.Type}, {"Two", type text}, {"Three", type text}})
            in
                #"Changed Type",
        #"d:\testdata\files\_Sales_2013-02-01 csv" = Source{[#"Folder Path"="d:\testdata\files\",Name="Sales_2013-02-01.csv"]}[Content],
        Loaded = Loader(#"d:\testdata\files\_Sales_2013-02-01 csv")
    in
        Loaded
    Now I apply the same function to all of the rows, transforming the existing "Content" column into a new value:
    let
        Source = Folder.Files("d:\testdata\files"),
        Loader = (file) =>
            let
                #"Imported CSV" = Csv.Document(file,null,",",null,1252),
                #"First Row as Header" = Table.PromoteHeaders(#"Imported CSV"),
                #"Changed Type" = Table.TransformColumnTypes(#"First Row as Header",{{"One", Int64.Type}, {"Two", type text}, {"Three", type text}})
            in
                #"Changed Type",
        Transformed = Table.TransformColumns(Source, {"Content", Loader})
    in
        Transformed
    Finally, I need to expand out the columns in the table, which I can do by clicking on the expand icon next to the Content column header. The resulting query looks like this:
    let
        Source = Folder.Files("d:\testdata\files"),
        Loader = (file) =>
            let
                #"Imported CSV" = Csv.Document(file,null,",",null,1252),
                #"First Row as Header" = Table.PromoteHeaders(#"Imported CSV"),
                #"Changed Type" = Table.TransformColumnTypes(#"First Row as Header",{{"One", Int64.Type}, {"Two", type text}, {"Three", type text}})
            in
                #"Changed Type",
        Transformed = Table.TransformColumns(Source, {"Content", Loader}),
        #"Expand Content" = Table.ExpandTableColumn(Transformed, "Content", {"One", "Two", "Three"}, {"Content.One", "Content.Two", "Content.Three"})
    in
        #"Expand Content"
    From here, you should be able to get to what you want.

Maybe you are looking for

  • Can I use Final Cut Studio 2 software on a MacBook Air?

    My old MacBook Pro was stolen a couple of years ago and I replaced it with a MacBook Air OSX 10.9.5. I still have the software from Final Cut Studio 2  which I used on my MacBook Pro. I haven't got around the replacing this and was looking at the Fin

  • Photo gallery limited to 5 pages?

    I have over 200 photos for some of my galleries. I would prefer to keep around 20 or so photos per page, but it seems iWeb limits the number of pages to 5, and it wont display the remaining photos. Is there a setting somewhere that tells it to limit

  • Can you "Extend Features in Adobe Reader" via Distiller Server 8?

    We use Distiller Server 8 to generate upwards of 500 PDF files (soft proofs of ads) each day. We would like the recipients of these files to be able to attach comments and markup the PDFs as a way of providing corrections back to us. The vast majorit

  • Quality issues w export to MPEG2-DVD

    I'm using CS4, creating moving still images, some directly in the timeline and some from After Effects. The pictures (imported at resolutions above the timeline SD widescreen rate and then scaled down) in the timeline in the Program box and on my sep

  • Work schedule rule in production system..

    Dear experts, We have created new personal sub area and new work schedule rule.Everything is working properly in Dev system.. But in production we could not get work schedule rule in work schedule rule field (pressing F4 we are not getting list of ru