Extracting part of a file name

I have a file with the naming convention as such:
AR999 Smith, Bob EM v1.mov
I need to extract out the v1 part. Other files may have the same name but with a v2, v3,v4 etc on the end so I will need to know what version number we are on. How do I set up a variable that knows what the version number the file is. for example
set the_version to last text item of a_file
then the_version variable would equal, v1
something like that.
I know you have to use Applescript text item delimiters, I just cannot make it work.
thanks

If you know the format of the text string, there are several different ways to get the last couple of characters - text item delimiters, text range, word item, etc. The following example gets the last word of a file name:
<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">
set SomeItem to (choose file)
set {name:TheName, name extension:TheExtension} to (info for SomeItem)
if TheExtension is in {missing value, ""} then
set TheExtension to ""
else
set TheExtension to "." & TheExtension
end if
set TheName to text 1 thru -((length of TheExtension) + 1) of TheName -- just the name part
set TheVersion to the last word of TheName
display dialog TheVersion
</pre>

Similar Messages

  • SSIS - creating part of the file name from an id in the database

    I am trying to figure out how to pull an "id" from my data source to include in the file name. Right now the file name created looks like customer_002_timestamp.txt. I need to add the id to the file name and I need to grab it at the time I get
    the data, so then the file name becomes customer_002_id_timestamp.txt.
    My data source is Oracle and I am using Attunity, so I do not have the capability of using the resultset found in the SQL Task because I have to use the data task.
    Has anyone ever extracted an id from a query against Oracle using the Attunity connector to add as part of the file name? If so, how would I add that to my control flow task?
    Thanks in advance for any assistance.

    Is it a static id value you want
    Then you can just use a SSIS variable to hold value from resultset in execute sql task
    Then inside your data flow you can use an expression for setting value of another variable which can be used for setting filename in your destination task. The expression will include logic to concatenate id variable also which we populated in the previous
    step.
    Please Mark This As Answer if it solved your issue
    Please Vote This As Helpful if it helps to solve your issue
    Visakh
    My Wiki User Page
    My MSDN Page
    My Personal Blog
    My Facebook Page

  • Part of sender File name at the receiver side?

    Hello All,
    My requirement is like this.
    iam picking the file from FTP server and place the file in another FTP server with out mapping.
    I need to use part of sender file name to create the receiver side along with current date.
    for example.
    sender side file name : LM01000008.txt
    recevier side file name need to generate : LM01dd/mm/yyyy
    Please let me know how to achive this.
    i tried with the blog given below, but partial file name is not possible with that blog.
    http://www.sdn.sap.com/irj/scn/weblogs;jsessionid=(J2EE3417100)ID0229698450DB11989196758750510369End?blog=/pub/wlg/6400
    Thanks and Regards,
    chinna

    Hi Chinna,
    Use this code
    DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
    DynamicConfigurationKey key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File","FileName");
    SimpleDateFormat dateformat = new SimpleDateFormat("yyyyMMdd");
    String timestamp = dateformat.format(new Date());
    String newfilename=fileName+timestamp+".txt";
    // change to new file name
    conf.put(key, newfilename);
    return "";
    Regards
    Suraj

  • Reading a File by Knowing a part of the file name

    Hi Java Gurus,
    Can I copy a file to another location by knowing a part of the file name.I know the extension of the file and part of the file name.Can I copy such a file to another directory?
    Eg :
    0099999999_JAPPLIC_20090320.pdf is the file name.
    I know the file name contains 'JAPPLIC' .Can I use this clue and the extension of the file to copy the file to another directory.
    Please let me know whether it is possible or not.
    Regards,
    Rakesh.

    Hi ,
    I used the below code and I was able to solve the problem.I was able to select the files of the required extension and serach for the file names containing the text I know and use such files and move to another directory.It may be helpfulk to you people
    public class FileDeletion {
    public static void main (String args[]) {
         String e = "";
         String d = "C:\\TCCTouchpoints\\Attachments_Export\\outbound";
         String newFileLoc = "C:\\TCCTouchpoints\\Attachments_Export\\move";
    ExtensionFilter filter = new ExtensionFilter(e);
    File dir = new File(d);
    File newLoc = null;
    String[] list = dir.list(filter);
    if (list.length == 0) return;
    System.out.println("File Length "+list.length);
    ArrayList fileNames = new ArrayList();
    for (int i = 0; i < list.length; i++) {
    /*file = new File(d + list);
    boolean isdeleted = file.delete();
    System.out.print(file);
    System.out.println( " deleted " + isdeleted);*/
         System.out.println(list[i]);
         if(list[i].contains("_F5029.03_")){
              fileNames.add(list[i]);
              //System.out.println(list[i]);
    dir = null;
    for(int i=0;i<fileNames.size();i++){
         dir = new File(d+"\\"+fileNames.get(i));
         newLoc = new File(newFileLoc+"\\"+fileNames.get(i));
         if(dir.renameTo(newLoc)){
              System.out.println(dir + " is moved to "+ newLoc);
         }else {
              System.out.println("***** " dir " is not moved to "+ newLoc);
         dir = null; newLoc = null;
    for(int i=0;i<list.length;i++){
         dir = new File(d+"\\"+list[i]);
         dir.delete();
    class ExtensionFilter implements FilenameFilter {
    private String extension;
    public ExtensionFilter( String extension ) {
    this.extension = extension;
    public boolean accept(File dir, String name) {
    return (name.endsWith(extension));
    Thanks for replying .......

  • How to not append '.PART' to the file name of the currently downloading file, and just download the file with its normal filename

    In Windows, when Firefox (I'm currently using 7.0) downloads a file, it appends ''.PART'' to the file name of the currently downloading file and just renames it to its original file name after it finishes downloading.
    I sometimes like to watch a currently downloading video file, so it will be better if Firefox just downloads the file to its actual filename (like what Opera does), so I can easily double click the incompletely downloaded file and watch it with the video player assigned to that file extension, rather than the awkward ''Right click -> Open With -> Choose Default Program'' route with .part files.
    Does anyone know how to set Firefox to do this?

    It is possible that your anti-virus software is corrupting the downloaded files or otherwise interfering with downloading files by Firefox and prevents Firefox from renaming the .part file.
    Try to disable the real-time (live) scanning of files in your anti-virus software temporarily to see if that makes downloading work.
    See "Disable virus scanning in Firefox preferences - Windows"
    * http://kb.mozillazine.org/Unable_to_save_or_download_files

  • When I download files, firefox is adding " .part " to the file name and the file won't open, but if i back the .part out, it opens fine.

    Firefox seems to be adding " .part " to the file names of files I downoad. Here's an example:
    YuT9iNv8.pdf.part
    I cannot open this file because it can't find an application.
    If I back out the .part, I get a box asking if I want to change the extension to .pdf I check yes, and everything works fine. It doesn't happen with other browsers (Safai).

    I get the error message saying the file could not be downloaded due because there is no enough disk space.
    How large is your HD and how much space do you have left?

  • Extracting string from a file name

    Hello,
    I have a legacy (read: I didn't build it) SharePoint list  that includes some validation when uploading files that's giving me some trouble.
    Basically, our users are required to add files to a list in a certain filename format and based on the naming convention are approved/rejected and routed to the appropriate location.
    One of the validations looks at a section of the file name and compares it to a folder name in the library.
    For example, the file name format is XX_AAA_999_2014_05.xlsx and that matches on the folder name of /submissions/2014_05
    Currently the rule says look at the last 7 characters of the folder and the 7 characters starting at position 12 of the filename and make sure they match.
    The problem is the 999 in the example above is a sequential identifier to the project a file is associated with... e.g. they range from project 000 to project 999. We've now hit project 1000 so file being added for project 1000 (and beyond) fails because
    the starting position has shifted one spot. (Note: we have active 3 digit projects so I cannot simply change that to be position 13... not to mention what that does to my history).
    So, my task is to come up with something that can accomodate 3 or 4 digit numbers.
    I'm trying to stick as closely to the original setup so I don't mess up the history so I'm looking at other methods of getting to the same data in the string.  Another problem is that the file names include the extension and the extension can be 3 (pdf)
    or 4 (xlsx) characters long.
    I've tried this:  =LEFT([Source File Name],SEARCH(".",[Source File Name])-1)
    but that brings back everything in front of the period and I need just the 7 preceeding characters.  Is there a way to limit the number of chars a LEFT() function returns?
    In a nutshell, the 4 variations of file names are as follows of which I need to extract the
    bolded section.:
    ZZ_AAA_999_2014_05.xls
    ZZ_AAA_999_2014_05.xlsx
    ZZ_AAA_1000_2014_05.xls
    ZZ_AAA_1000_2014_05.xlsx
    Thanks!
    Kevin

    Hi,
    According to your description, you might want to retrieve the string “2014_05” from the file name.
    I would suggest you create a SharePoint Designer workflow and implement your logic of handling the filename.
    In SharePoint Designer 2010, there are already some useful utility workflow actions which can enable users to deal with the various requirements come from the business scenarios.
    For the string handling, you can consider to use the
    Utility Actions:
    http://msdn.microsoft.com/en-us/library/office/jj164026(v=office.15).aspx
    Another two links about creating SharePoint Designer workflow for your reference:
    http://office.microsoft.com/en-001/sharepoint-designer-help/introduction-to-designing-and-customizing-workflows-HA101859249.aspx
    http://www.codeproject.com/Tips/415107/Create-a-Workflow-using-SharePoint-Designer
    Thanks
    Patrick Liang
    Forum Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact
    [email protected]
    Patrick Liang
    TechNet Community Support

  • 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.

  • Rename files and move them into new folders with part of original file name

    I have tried using automator and other programs such as name Name Mangler with no luck.
    I am trying to have an AppleScript run when files are added to a folder, using a service through Automator.
    File names come in 9 different suffixes, all with the same prefix.
    Example:
    nonspecificprefixSUFFIX
    nonspecificprefixOTHERSUFFIX
    nonspecificprefixALSOSUFFIX
    I am trying to get the program to create a folder named after the prefix, then to remove the prefix from the files after moving them into this folder.
    There are 9 different suffixes that should remained unchanged.
    End goal would be to have child folders named nonspecificprefix, nonspecificprefix2 etc each with 9 files only containing the suffix portion of original name.
    If anyone has any tips to get me on the right path that would be much appreciated! I have thousands of files to rename and move so this would save me loads of time!

    Erwin,
    I was not able to systematically examine this issue, because it occurred on a production system and, of course, I uninstalled the Adobe iFilters as soon as I read that they may delete pdf files. Before the uninstallation I noticed the AR9 folders appearing on c:\ and moved them from time to time to another folder. Using the search function inside this folder, I found that all files were present in duplicate at least. I concluded, that after moving the AR9 folders they were recreated containing the same files. Consequently, these files cannot have been deleted. Searching for the origin of these files I found that they were part of pdf portfolios, therefore my conclusion that they are part of the indexing mechanism of the portfolios. What I have not done (and what I am not going to do since it is a production system) is to fill a folder with pdfs and track what is happening to the files.
    In case of my server, I think that the iFilters did not delete any files. Of course I cannot say what happens on other systems. I am definitely not going to reinstall the iFilters before knowing what they a really doing to the files.
    Not sure if this is of much help
    Michael

  • Extracting Pages and naming file names of pdfs

    I need to be able to extract pages from a large file to create seperate pdf documents for each page. When I do this the file name for each page is for instance "Medical Records 1.pdf"; "Medical Records 2.pdf".... Medical Records 11.pdf"
    Here is the problem. When I go to review them in order the page (document) that is numbered 2 will not be after "1" but rather just before "20" and "3" is out of order and just before "30". When the number of pages is 600 plus this is a problem. This would not happen if there was a leading "0" before the "2" , "3", "30" etc. This happens with single digits and double digits as well since the page numbers are in the hundreds.
    Any ideas on how to correct this issue? Thanks in advance.

    This sounds like an issue with the sort order display in Windows Explorer. If you use the File > Open dialog in Acrobat the files should display correctly.
    If you're previewing the PDFs in Windows Explorer try clicking the Name button underneath the toolbar to change the sort order from ascending to descending, then a single click again should display them correctly.

  • Is there a way to have compressor create files without have the settings name as part of the file name?

    It's very annoying to have to delete half of the file name each time.  Is there a way to just have it pop out as whatever you want to title it and the file extension?

    In Compressor 3 - Create a custom destination, where you want to save the compressed files.
    Once it is created, click on the custom destination and look in the Inspector - you will see the Output Filename Template for the destination. Delete the "- Setting Name" so that it just says "Source Media Name".
    Now apply this destination to your clips to be compressed.
    In Compressor 4, I believe the default is just the file name, but you can modify it in the same way by using the inspector for your custom destination when you create a custom destination.
    MtD

  • File-File - Need to extract data from source file name???

    Hello Experts,
    I have a unique situation. In my file to file scenario, the source file name is of the format XYZ_yymmddHHMM.dat. there is field in the target file which has to filled with the date that is there in the file name of the source file (yymmdd). How can this be achieved? Normally we do the other way round using vaiable substitution where we can name a file depending on the value in any of the target field structure.
    Please help.
    Regards,
    Yash

    Hi,
      please prepare the udf with the following code.
      i mean, dynamic configuration concept.
      where u get the file name, then use substring function to capture date from right side.
       //write your code here
    // getFileName User Defined Function
    // function to create name of output file
    String filename;
    filename = strFile;
    try {
    // initialize DynamicConfiguration for create file with given name
    DynamicConfiguration conf = (DynamicConfiguration) container
    .getTransformationParameters()
    .get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
    DynamicConfigurationKey key = DynamicConfigurationKey.create( "http://sap.com/xi/XI/System/File", "FileName");
    //create file with the specified name
    conf.put(key, filename);
    } catch (Exception ex) {
    return filename;
    warm regards
    mahesh.

  • FTP directory from part of PDF file name

    Hi,
    I have a requirement to FTP a pdf file to a server directory according to fist 10 char of the file name. I am able to get the file name using variable substitution method but how can i chop the 1st 10 char of file name as my directory? As the file is a .pdf i didn't do any data mapping.
    Thanks

    Hi,
       If you dont have any Mapping Objects,then writing adapter module to change file name is the right option
    or you can create dummy message mapping and add dynamic configuration UDF ,but in your case you trasfering PDF documents,this option is not feasible.
    or writing Java map is the other alternatine,but it is not recommanded to your requirement,because once again you need change the .add IR objects.
    Writen adapter module,
    add and chnage below code as per module and your requirement
    DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
    DynamicConfigurationKey key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File","FileName");
    SimpleDateFormat dateformat = new SimpleDateFormat("yyyyMMdd");
    String timestamp = dateformat.format(new Date());
    String filename_new=fileNametimestamp".txt";
    conf.put(key, filename_new);
    return "";
    Regards,
    Raj

  • Aperture: How can I batch change one part of a file name

    I have a file name format for my motor sport pictures
    EventNameYear_CarNumber_ImageNumber
    I have just named 600+ images but after publishing the images, I spotted I put the event year as 2014 instead of 2015.
    How can I batch change the year but leave everything else the same? I've been through the batch change options but cannot work it out
    I am on Aperture 3.6, MacBook Pro on Yosemite 10.10.2
    Thanks

    So you renamed the versions in Aperture, the rename was not just done on the export?
    The names could be changed either in Aperture or on the exported files but as was noted it would require a script to do it. Doing the rename on the exported files would be the easiest, Applescript or possibly even Automator or any number of 3rd party apps could handle this rather easily. Name Mangler comes to mind as possibly being able to handle this.

  • Extract part of .indd file

    Hi everyone,
    I would like to know if it is somehow possible to extract (export) a small part of a larger template. Specifically, I have a template for a book of articles, which is set up exactly as I want it to be. Is it possible to extract only one article from it (i.e., 6 pages from 200).
    I have tried several things, but neither worked.
    Thank you in advance.

    Make a new document with 1 page and ideally same page dimensions. Also open the source document.
    In the source document, select the 6 pages in the PAGES panel and from the mini menu chose "Move pages" and in the dialog select the new document.
    In the new document delete the one blank page that was created with the new document.
    Save new document.

Maybe you are looking for

  • How to print items in the MAIN window of the NEXT page (smartform)?

    Dear forumers, There are two pages (FIRST and NEXT) in my smartform with the same MAIN windows in each of the pages. Whatever that are changed in FIRST-MAIN window will also be seen in NEXT-MAIN window. I will need to control the printing of table TA

  • 110V vs. 220V, which is better?

    I'm going to be living for the next several months where I can use either 110V or 220V power. I know the charger is dual voltage, and I can use it with either voltage with a simple plug adapter. My question is, which is preferable? Will the battery c

  • My songs are all greyed out

    my songs are all greyed out on my laptop and I cannot get them to play

  • How do you white list messages in apple mail

    What is the procedure to whitelist messages in Apple Mail?

  • App store updated in 3.0?

    when i first installed 3.0 firmware, i noticed the app store had an extra icon, so i had to click the more option to get to my updates... now it's back to the way it was before.. i can't even remember what the icon was.. but is this icon meant to be