Set Folder Name From File Name Inclosed.

Hello scripters,
There has been quite a few topics about setting file names from parent folders. I believe it's possible but not sure how to reverse this process. That is to say set the folder name from a file in the folder. This is what I'm imagining.
I've got a folder. In the folder are 100 folders with the names "untitled folder xxx" In side I've got files that are all named and numbered.
For example,
untitled folder/B-day 001~050.jpg
untitled folder 50/At The Park 001~020.jpg
I would like a script to change the name of the parent folder of the files that it houses.
So untitled folder becomes
B-Day
untitled folder 50 becomes
At The Park
etc…
I think getting the name of the first file (minus the index number) would be easiest.
Any help or futher questions are greatly appreciated.
Maximilian

Working backwards...
Assuming all the files have the same name structure (e.g. end in the format "xxx~xxx.jpg" you can get the base name using:
<pre class=command>set baseName to characters 1 through -13 of filename as text</pre>
This cuts off the last 12 characters of the file name.
Once you have a folder, you can get the names of files in the folder via the Finder. for sanity's sake I'd ask the Finder for the first item, just in case there's more than one file:
<pre class=command>set filname to name of first item of (files of folder theFolder)</pre>
And if all the folders are in one top folder, you can iterate through them like:
<pre class=command>repeat with eachFolder in (every folder of folder topFolder)</pre>
So now, string it all together:
<pre class=command>tell application "Finder" -- we'll use the Finder to do the legwork
set topFolder to (choose folder with prompt "Choose the top level folder" ) -- get the top folder
repeat with eachFolder in (every folder of folder topFolder)
set fileName to name of first file of (files of folder topFolder)
set baseName to characters 1 through -13 of fileName as text
set name of folder eachFolder to baseName
end repeat
end tell</pre>
Note there's no error checking - the script will fail if there are no files in any particular folder, but it should get you going.

Similar Messages

  • What is the b2b setup for identifying TP names from file name in Inbound tx

    Hi,
    I am using B2B 11g version and documents of type ANSI-X12. I am working for Inbound Transaction and using Generic File protocol in Listening channel.
    File format is : %FROM_PARTY%_%TO_PARTY%_%DOCTYPE_NAME%_%DOCTYPE_REVISION%.dat
    How can i make B2B to identify Trading partner names from the file name once the remote trading partner put the file in the specified path with the specified format "%FROM_PARTY%_%TO_PARTY%_%DOCTYPE_NAME%_%DOCTYPE_REVISION%.dat" mentioned in the delivery channel.
    Now B2B is identifying Trading partner names from the Interchange Sender ID(ISA06) and Interchange Reciever ID(ISA08) of the ISA Segment. Please help me , how to make B2B to identify the trading partner names from the file name instead of from identifiers coming in ISA Segment.
    Thanks,
    Sridhar Rachumallu

    Hi Anuj,
    1)Now i am giving the file name for inbound documents in the format of "%FROM_PARTY%_<UniqueNumber/Timestamp>.dat" . But still B2B Identifying the TPNames at runtime from the ISA Segment elements ISA06 & ISA08 element values. I want to make B2B to identify the TPNames at run time from the file name instead of from ISA Segments.
    Please tell me how can i do these?
    2) I am giving exact Remote Trading partner Default Identifier Type 'NAME' value for "%FROM_PARTY% in the file format and i want B2B to identify the TP name at runtime based on the value of "%FROM_PARTY%" . If the value of "%FROM_PARTY%"is matching with any one of the Trading partner Default Identifier Type 'NAME' value than it should go for furthur else B2B should through error as " the TP name unable to found".
    3) Please tell me how B2B Identify trading partners at runtime in the business case given below
    - Inbound Transaction from remote TP to Host TP
    - Document protocol is 'ANSI-X12'
    - Listening channel protocol is 'Generic File'
    This is very urgent.. Please give the reply As soon as possible.
    Thanks,
    Sridhar.rachumallu
    Edited by: [email protected] on Jun 9, 2010 12:45 AM
    Edited by: [email protected] on Jun 9, 2010 1:01 AM

  • EXS24 read root key from file name only

    Has anyone encountered this with EXS24 in Logic 7? If you set preferences to "read root key from file name only" then EXS reads the root key from the file itself when loading samples. On the other hand if you set them to "read root key from file only" then it reads the root key from the file name. Or am I just imagining this?
    P.S. if anyone from Apple is reading, could you please update EXS24? It's a bit primitive by today's standards.

    Hi
    Not a direct answer to your question, but if you are doing a lot of sample mapping etc, you may want to check out Redmatica's KeyMap Pro or the simpler Keymap 1:
    http://www.redmatica.com
    CCT

  • Cloud does not disappear from file name?

    why does it take "forever" for the cloud to disappear from file name?
    I saved a numbers document to the cloud a half an hour ago, and the cloud is still there.

    HDash-Tech,
    thanks for the tip, but since I have my iTunes Library on a NAS I have to direct iTunes every now and than via "choose library" to the folder and it doesn't make a difference...
    I think it's somehow due to my iTunes Match.  I know they do not sync audiobooks, but they mess up pretty much everything else within my library.  Songnames here and there and especially cd covers!
    Any other idea how to get it straigten out again?
    Thank,
    Daniel

  • Batch document title from file name?

    Forgive the newb question on a fairly simple matter.
    I want to create File Info: Document Titles from file names, minus the extension, for about 400 images.
    Is this possible with Batch rename, if so what am I missing?
    Thanks,

    I am unclear how a batch rename will enter data into File Info: Document Title.
    I have never used them but you might look at metadata templates.  Several sites on web on how to set them up and what they will do for you.

  • B2B identifying TP from file name and not Interchange

    We want B2B to identify trading partner from ISA/GS segment, but B2B is taking it from file name. We have property oracle.tip.adapter.b2b.edi.identifyFromTP set to "Interchange". As I understand based on the tip.property it should always take from the ISA/GS segment in dat file.
    We also have Trading Partner Identification Type set to EDI Interchange ID while setting up trading partner and it is set to the same value as Interchange Receiver Id in the Document Protocol.
    Anyone has any ideas?
    Thanks

    Hello Venkat,
    ideally this should work. Guess you have not restarted b2b after changing the tip.properties. If you still have issues, please raise an SR and also send the b2b.log in DEBUG mode.
    Rgds,Ramesh

  • Remove LF characters from file names

    I have a folder full of files with filenames that contain LF character (ASCII code 10).  I want to use Automator's "Replace Text" funcion to remove these non printing characters from file names.  Is there a way to do it?
    If automator is not able to do this task, I will take a bash script or applescript solution as well...

    Take a look at: http://stackoverflow.com/questions/4417588/sed-command-to-fix-filenames-in-a-dir ectory
    (I changed  tr -d "\r\n" to tr -d "\n", but try both)
    for f in ~/Desktop/*
    do
        new="$(printf %s "$f" | tr -d "\n")"
        if [ "$f" != "$new" ]; then
            mv "$f" "$new"
        fi
    done

  • File type from file name

    Hi,
    Is there any standard method to get a file type from file name?
    File name can be ‘C:\test.doc’ or “C:\test’(test – is file) i.e. with or without file type extension.
    ...Naddy

    You can use the Function module PC_SPLIT_COMPLETE_FILENAME
    export paramter extension will tell the type of file
    Sample Output
    Import     COMPLETE_FILENAME     C:\TEST.TXT
    Import     CHECK_DOS_FORMAT     
    Export     DRIVE     C
    Export     EXTENSION     TXT
    Export     NAME     TEST
    Export     NAME_WITH_EXT     TEST.TXT
    Export     PATH     \

  • WCF Service and Sharepoint Form library : How i can read a access a form libray and query a item from file name and read form xml in WCF service ?

    WCF Service and Sharepoint Form library : How i can read or access a form libray and query a item from file name and read form xml in WCF service ?
    Ahsan Ranjha

    Hi,
    In SharePoint 2013, we can take use of REST API or Client Object Model to access the SharePoint objects like Form Library.
    SharePoint 2013 REST API
    http://msdn.microsoft.com/en-us/library/office/dn450841(v=office.15).aspx
    http://blogs.technet.com/b/fromthefield/archive/2013/09/05/working-with-sharepoint-list-data-odata-rest-and-javascript.aspx
    SharePoint 2013 Client Object Model
    http://msdn.microsoft.com/en-us/library/office/fp179912(v=office.15).aspx
    http://msdn.microsoft.com/en-us/library/office/jj193041(v=office.15).aspx
    With the retrieved file, we can then use XmlDocument object to parse it and get the values you want:
    http://weblogs.asp.net/jimjackson/opening-and-reading-an-xml-file-in-a-document-library
    http://stackoverflow.com/questions/1968809/programatically-edit-infopath-form-fields
    Best regards
    Patrick Liang
    TechNet Community Support

  • Need help with EXS24 "read velocity range from file name"

    I am trying to import 127 drum samples to a single key using the option shown here. The option says "Map to key dropped on and read velocity range from file name". I can find no documentation in the manuals on how to do this. What is the syntax required in the file name to make this work? I need to do several of these imports. The capability is cleary there, but I need help on how the file name should be formatted. My thanks to anyone who can help.

    Hi
    Not a direct answer to your question, but if you are doing a lot of sample mapping etc, you may want to check out Redmatica's KeyMap Pro or the simpler Keymap 1:
    http://www.redmatica.com
    CCT

  • Removing date from file name

    Hello,
    Is there any way to move all the file from one location to another and remove the datepart from filename.
    for eg:- if file name is abc_20150411.xls change to abc.xls. if file name does not contain date part then ignore it.
    Can any one suggest if its possible.
    Thank You

    Hi ,
    I have created package based on your question and decribed in detail in below post:-
    https://msbitips.wordpress.com/2015/04/12/ssis-removing-datestamp-from-file-name-when-moving-from-one-location-to-other/
    You need package code, just add comment in this thread.
    Thanks
    Prasad
    Mark this as Answer if it helps you to proceed on further.

  • How can I extract metadata from file names?

    If I want to extract metadata from file names? How can I do that? I want to read through the file names and when I get to a certain character ("-"), I can take the string just before that character and store it in a column in SharePoint. Is this
    do-able through scripting? 

    If I want to extract metadata from file names? How can I do that? I want to read through the file names and when I get to a certain character ("-"), I can take the string just before that character and store it in a column in SharePoint.
    Is this do-able through scripting? 
    You should be able to leverage the split method.
    In PowerShell It would look like:
    # Gather the file name
    $file = "myawesome_filename-Month-Day-Year-Ect.doc"
    #split the file name by the "-" character
    $file = $file.split("-")
    # Use a foreach Loop to gather the individual items.
    foreach ($item in $file) {
    write-host $item
    #Outputmyawesome_filename
    Month
    Day
    Year
    Ect.doc
    # If you want to only grab the first item, you can do $file[0] <-- powershell starts counting with zero base.
    $file[0]
    #output
    myawesome_filename
    Entrepreneur, Strategic Technical Advisor, and Sr. Consulting Engineer - Strategic Services and Solutions Check out my book - Powershell 3.0 - WMI: http://amzn.to/1BnjOmo | Mastering PowerShell Coming in April 2015!

  • Discoverer Report: How to find Business Area name from Report Name.

    Hi
    I opened a report in Disco Desktop 4 -> Resonsibiolity --> Report Name.
    So I know Report name but don’t know which Business Area it belongs to.
    How to find Business Area Name from Report Name?
    Cheers
    Vijay

    Hi,
    There is no relationship between reports and business areas. Each report can be built from many folders. Each folder can be in many business areas.
    However you can try the following SQL which may give you the result you want for an v5 EUL. You will have to modify for Discoverer 4 EUL:
    select distinct doc_name, obj.obj_name folder_name, bas.ba_name
    from eul_us.eul5_documents doc
    , eul_us.eul5_elem_xrefs xref
    , eul_us.eul5_expressions exp
    , eul_us.eul5_objs obj
    , eul_us.eul5_ba_obj_links bol
    , eul_us.eul5_bas bas
    where xref.ex_from_id = doc.doc_id
    and doc.doc_name = &your_report
    and xref.ex_to_id = exp.exp_id
    and obj.obj_id = exp.it_obj_id
    and bol.bol_obj_id = obj.obj_id
    and bas.ba_id = bol.bol_ba_id
    Rod West

  • Clip name to file name

    Needs to be away to make clip names to file names.
    Some files are loaded by other people. They did not name the file right.
    It would be nice to have a plugin or apple scrip to do this.

    Actually, it's not exactly an automatic procedure - just because you change the name in the Browser, doesn't mean the .mov on your hard drive gets changed. You actually have to either go Modify > Rename (from the Menubar) or control-click with the clips in question corrected, to even get the options.
    And, for what it's worth, there is also the option to go backwards (Match Clip to File Name) for the instances when folks get a little to crazy with the clip renaming.
    As for file name changes, the renaming does not cascade through to closed projects, you'll have to relink media the next time you open them. However, in a nice touch, FCP does re-write the source property for clips in other open projects - that are linked to the media file in question - when you alter the file name (so those clips won't go offline).

  • X79A-GD65 (8D) MSIHQ error 654 Specified path name or file name is invalid.

    Hello,
    First, excuse my poor english...
    I would like to flash the 7760 v1.8 bios of my motherboard to install windows 8.1 on a crucial M500 480Go (yet, installing W8.1 after connect M500 on SATA1 6Go next to my M4 SSD with W7, causes errors during installation and I guess it is because i think the SSD is not correctly recognized by the bios and Windows 8.1 requires bios and ME updates.)
    I download the last bios on MSI site (http://us.msi.com/product/mb/X79AGD65_8D.html#/?div=BIOS) and install MSIHQ Tool 1.25g software to make an USB stick for flashing as describe here : https://forum-en.msi.com/index.php?topic=116721.0
    But when i point on the archive (3.1. Method 1: Processing a BIOS Archive Directly (ZIP/RAR)), MSIHQ can not open the archive and tell me: ERROR 654 Specified path name or file name is invalid.
    Yet when I use the same method to flash my bios from 1.6 to 1.8, it had gone well ... What to do?  Should I use the method described on the download page: http://fr.msi.com/files/pdf/Bios_update_SOPAll.pdf ?
    Thank you and good day.

    No, no...  I know what a dual boot if it is what you say, I did it for years. I also made two differents drives with two separate systems boot : a Hdd with xp and boot.ini , and another with windows 7 and mbr. After installing the first OS first on a disc, you disconnect this HDD and connecting the second to receive the second OS. There is no dual boot because I did not boot on the same partition then let me choose between 2 OS placed on two differents drives or two partitions, but I boot well on two differents disks , each with their own boot files this just saves me the dual boot which I find too heavy. On a Gigabyte X48T -DQ6 with the F12 key , you choose what HDD boot . Same I think with the F11 key X79A - gd65 : "Press DEL key to enter Setup Menu , F11 to enter Boot Menu" and then you choose between booting on either disc. In the case cited above , it is then that we arrive on the mbr of windows 7 on a disc or boot.ini windows xp on the other. So you do not answer my question, it seems to me :-) I wonder if I'm clear, there ...;-)
    thanks very much...

Maybe you are looking for

  • X6-00 16GB Software Update problem

    I have a X6-00 16 GB and i have tryed to update my phone via the Nokia Suite (v3.2) but there are "no updates available"...  I know that tere is a new firmware out there for this phone (v32), adn today I read that somebody can even update to v40 but

  • Prevent Folder Deletion w/ Password Protect on USB?

    I've seen similar topics but not specific to my needs. I need to prevent folders on a USB / flash drive from being deleted - hopefully with password protection software or something similar (I've done a million hopeless searches). MOST IMPORTANTLY, t

  • Battery is Lame!!!!!

    Hi all knowing mac people. Need a little help....... I have a powerbook 15'' 1.67 (not the new one... 2nd to newest) I read on the apple site that you should reset your battery by charging it full and then leaving it for 2 hours I might have not left

  • Trouble with double byte swapping routine

    I'm working on a program that reads little endian doubles from a DataInputStream and then swaps them. Usually, everything works fine. However, certain values don't swap correctly. I'm at a total loss as to why this is happening, so I hoped one of you

  • SCEM WCL modification

    Hi experts, We are working with SCEM 5.0 - Web Interface, and we are triying to modify the calls to standard BAPIs which retrieve event handler /SAPTRX/BAPI_EH_GET_DATA_GEN and /SAPTRX/BAPI_EH_DISPLAY_DATA. Instead we are creating a wrapper Z-BAPI as