Trim first 6 characters from Folder Names [AppleScript]

Hi all,
I've found an AppleScript online which trims the first characters from a FILENAME, however, it does not seem to work on FOLDERS.
How could this be modified to rename folder names?
set whichFile to choose file with multiple selections allowed repeat with aFile in whichFile tell application "Finder" set filename to name of aFile set name of aFile to ((characters 7 thru -1 of filename) as string) end tell end repeat
Thank You!

Here:
set whichFile to choose folder with multiple selections allowed
repeat with aFile in whichFile
tell application "Finder"
set filename to name of aFile
set name of aFile to ((characters 7 thru -1 of filename) as string)
end tell
end repeat
(105621)

Similar Messages

  • 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

  • Selecting the first 4000 characters from a tag in an xml file

    Oracle Enterprise Edition 11.1.0.7 64 bit (Jan 2012 CPU applied)
    Windows 2003 64 bit
    We have an XML file with the following sample format.
    <?xml version="1.0"?>
    <HR>
    <EMP>
    <FNAME>JOHN</FNAME>
    <LNAME>DOE</LNAME>
    <COMMENT>Comment with less than 4000 characters</COMMENT>
    </EMP>
    <EMP>
    <FNAME>JANE</FNAME>
    <LNAME>DOE</LNAME>
    <COMMENT>Comment with more than 4000 characters</COMMENT>
    </EMP>
    </HR>
    The query below
    (full disclosure: which I took from odie_63's response in Creating External Table using Xml Dataset - how to include null values? and added the CURSOR_SHARING_EXACT hint on the top)
    works when the contents of the <Comment> tag are smaller than 4000 characters. If it is more than 4000 I get
    ORA-01706: user function result value was too large
    SELECT /*+ CURSOR_SHARING_EXACT */
    FROM XMLTable(
    '/HR/EMP'
    passing xmltype( bfilename('DATA_PUMP_DIR','emp.xml'), nls_charset_id('CHAR_CS') )
    columns
    first_name varchar2(30) path 'FNAME',
    last_name varchar2(30) path 'LNAME',
    comments varchar2(4000) path 'COMMENT'
    I found another query where someone was doing a substring (I think to get only the first 4000 characters from the tag) here.
    http://www.ibm.com/developerworks/forums/thread.jspa?messageID=14638197 (See OP's post)
    TERMINATION_DATE VARCHAR(32) path 'TerminateDate/substring(text(), 1, 32)',
    So I updated my query to be
    SELECT /*+ CURSOR_SHARING_EXACT */
    FROM XMLTable(
    '/HR/EMP'
    passing xmltype( bfilename('DATA_PUMP_DIR','emp.xml'), nls_charset_id('CHAR_CS') )
    columns
    first_name varchar2(30) path 'FNAME',
    last_name varchar2(30) path 'LNAME',
    comments varchar2(4000) path 'COMMENT/substring(text(),1,4000)'
    The query runs without an error when the <comment> tag has 4000 or less characters but still errors out with it is more than 4000.
    I found an alternative method to do the SUBSTRING here in Herald ten Dam's reponse in Re: A view over XML that is not 1:1
    code varchar2(30) path 'substring(code,1,3)',
    so I tried this:
    SELECT /*+ CURSOR_SHARING_EXACT */
    FROM XMLTable(
    '/HR/EMP'
    passing xmltype( bfilename('DATA_PUMP_DIR','emp.xml'), nls_charset_id('CHAR_CS') )
    columns
    first_name varchar2(30) path 'FNAME',
    last_name varchar2(30) path 'LNAME',
    comments varchar2(4000) path 'substring(COMMENT,1,4000)'
    but that doesn't work either.
    How can I extract the first 4000 characters of the <COMMENT> tag so that the query doesn't fail.
    We are not using any other XMLDB features at this time. This is the first we've started looking into using Oracle built in XML features, so we might not have setup something that other's might know to specifically setup to start using the XML features in Oracle 11.1
    Thanks in advance,
    Wally

    walls99 wrote:
    This is regardless of the COMMENTS tag being 4000 characters or more and the same with the ideas from Odie.
    WallyNo idea if it is an issue with your version. I don't have your version to test but following works for me. Does this simple test work?
    SQL> select * from v$version ;
    BANNER
    Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
    PL/SQL Release 11.2.0.1.0 - Production
    CORE    11.2.0.1.0      Production
    TNS for Linux: Version 11.2.0.1.0 - Production
    NLSRTL Version 11.2.0.1.0 - Production
    SQL> set define off
    SQL> select dbms_xmlgen.convert(xmlserialize(content xmltype('<brand>Ben &amp; Jerry</brand>') as clob), 1) from dual ;
    DBMS_XMLGEN.CONVERT(XMLSERIALIZE(CONTENTXMLTYPE('<BRAND>BEN&AMP;JERRY</BRAND>')A
    <brand>Ben & Jerry</brand>

  • How to delete first few characters from all the elements of an array of strings

    hi
    I have a 2-dimensional array of strings length 104. I have to delete first 6 characters from all the elements of array and then change the strings to int. how to do it?? plz help

    Attached you can find the screenshot showing how to do so.
    Bye!
    Licia
    Attachments:
    array.jpg ‏14 KB

  • Application to grab text from folder names?

    I doubt there is software for this - if there isn't there needs to be - it'd make a killing!
    I'm looking for an app that can grab texts from folder names...what i mean is let's say
    on my desktop I have a folder titled "Movies", and inside that folder are hundreds of folders -
    each folder containing a movie.  Each folder is a title of a movie.  I would like to somehow select
    all of these folders and grab the text off of each folder - to catalogue my movies into a simple text file.
    I know I could open a word doc or txt doc and go one-by-one but i have thousands of movies and this
    would take forever. Please tell me there is an application that can save me some time with this.
    thanks.

    Niel - you rule!
    i couldn't get what you wrote to work - i tried inputting different paths, etc.  i'm probably doing something wrong -
    but i used this script
    tell application "Finder"
              get name of folders of folder ("/Users/macbookpro/Desktop/movies" as POSIX file)
    end tell
    and it worked. thanks again.

  • LR 2.1 Unable to Open as Smart Object in PS CS3 due to swedish characters in folder name

    When I try to open a raw file from Lightroom 2.1 as a smart object in Photoshop CS3 and the folder contains swedish characters, like åäöÅÄÖ, it will not open at all -> PH starts up and presents a "Open As" dialog.
    It works fine when I open images that is in a folder only having english characters...
    As I read that some apostrophe-related problems were fixed in the 2.1 release I hoped that it included all special characters allowed in folder names... The same problem occurs in version 2.

    My problem might be of a similar origin.
    I have also posted it on a different thread http://www.adobeforums.com/webx/.59b6903c
    I use mostly Hebrew characters for Keywording (the file names are in English) after opening in CS3 and saving, the keywords are converted from Hebrew fonts to accented fonts like åäöÅÄÖ.
    This didn't happen in LR1 and does not happen if I use CS3 as my secondary editor (not using the new LR2 edit in CS3 functionality)
    Shai

  • Replace not latin characters from file name.

    Dear friends,
    I tried a lot but even after reading the documentation about all the available CF functions I could not find a way  to accomplish this:
    As you already know from my previous post I'm trying to finish an application which manages multiple images. I have reached a really good point and I was ready to implement the solutions you suggest on this post when the client did something marvellous. He uploaded some images named "Εικόνα 123.jpg" (Image 123.jpg in English) which actually broke the Flex application that retrieves the images because the firewall does not allow high bit characters to go through. I now need to add a function that will evaluate every character in the file name individually and it will remove or replace (I do not care) all the characters that are not latin or numbers (spaces, greek characters, special characters, etc). As I've already said no known function is able to do that (as far as I know of course) and I guess that the solution could be hiding in regular expressions which is not my strong point. So I need your help here.
    Thank you in advance,
    John

    Thanks Ian,
    I cannot figure out how to use asc() function for this. I will have to run a test in every single character and replace the invalid ones but I will never now the actual string length (how many characters each image name will have) and I will  possibly end up destroying the extensions (.jpg) as well. To make it a little more complicated let me tell you that I will have to run this twice. Once for the full image path (ie d:\company\aptown\images\Εικόνα 123.jpg) in which I will have to change only the ...Εικόνα 123... part and not anything else, and once for a comma separated list of the image names (ie Εικόνα 123.jpg, Εικόνα 124.jpg, Εικόνα 125.jpg, Εικόνα 126.jpg). And don't be misleaded from the pattern. The customer may upload an image named with a complitely different way using invalid characters though, for example "Αντίγραφο της Εικόνας 123.jpg" (Copy of the image 123.jpg in English).
    Seems to be impossible ,
    I hope it is not.
    Yannis

  • Photoshop Automation Plug-in - Getting non western characters from layer names and layer text

    Hi To all members of the forum.
    My name is Momir Zecevic and i have developed automation plugin for  Photoshop and it work well for almost 8 years now (Windows XP, Vista, 8, Visual studio 97 and Photoshop 7 SDK). However client for which I have written plugin wants me to add possibility for  new version so that plug-in can read  international characters from text layers (Russian , French German etc) as well as layer names if they have international characters in it.
    I have tried  but seems that I am missing something obvious
    Here is example what I get from getter
    Example:
         error = sPSActionDescriptor->Make(&desc00000B28);
         if (error) goto returnError;
         error = sPSActionDescriptor->PutString(desc00000B28, keyName, "X????????X");
         if (error) goto returnError;
    Layer name is on cyrilic (i hope that it will be displayed right here) XШЂЧЋЖЊЕЏX
    Can someone point me in the right direction.
    Thank you very much.
    Regards,
    Momir Zecevic
    Ars Media
    www.arsmedia.tv

    Tom,
    Thank you very much on your response. i'll give it a try tomorow and post results here when i have them.
    Thanks again.
    Regards,
    Momir Zecevic

  • How to get the first 3 characters from the previous month?

    Hi,
    I need to get in a View Column only the first 3 characters of the previous month of data from the bellow query.
    SELECT ID, Department, Capital_Project_Number, 
    Capital_Site_Number, 
    Funding_Source, Milestone, 
    Account, Year, Month, Data
    FROM  Table
    Where Month = DATENAME(Month, DATEADD(Month, - 1, GETDATE())) and (Year = YEAR(GETDATE()));
    Go

     Left(DATENAME(Month, DATEADD(Month, - 1, GETDATE())),3)
    --Or
     convert( varchar(3), DATEADD(Month, - 1, GETDATE()),100)

  • Remove first 30 characters from get-content

    hello
    i have a one liner which reads a file and filter it based on my criteria. the output is very lengthy. i need to remove the first 35 characters of that in order to have a clear result with no unwanted information
    Get-Content D:\netlogon.bak | Select-String -Pattern "CHI-*"
    after I filter based on pattern, i want to remove the first 35 charaters. how can i do this?
    thank you

    Get-ContentD:\netlogon.bak
    | Select-String
    -Pattern
    "CHI-*" | %{$_.SubString(35,$_.Length-35)}
    \_(ツ)_/

  • Removing first few characters from an infoobjects

    Hi,
    I have an Infoobject where we load 9 character long records like - Ab1234567.
    I have to transfer everything to a new Infoobject but not the first 6 character. Could you please let me know the best code with all the details...I have limited ABAP knowledge
    Thanks for you help.

    Please search before you post -
    transformation routine: delete 4 first characters..
    First N characters

  • Spaces disappear from folder name when opened thrugh Web Client

    Hi,
    I am opening a pdf or word document through method EXECUTE  of class CL_GUI_FRONTEND_SERVICES.
    Now if there are more than one space in the path (ex. D:tes   t.pdf ) then file gets opened sucessfully if I log in through WIN client in SAP.
    But if i log in through SAP WEB client ,then only one space is retained in the URL and rest of the spaces are removed by method and I get a message "Path D:\tes t.pdf" not found.
    Any suggestions welcome?
    Regards,
    Mukul Sharma.

    Delete localstore.rdf or rename the file to localstore.rdf.sav in the [http://kb.mozillazine.org/Profile_folder_-_Firefox Profile Folder] to test if the file is corrupted.
    See http://kb.mozillazine.org/Corrupt_localstore.rdf
    (caution: do not delete the localstore.rdf file in the Firefox program installation folder)
    Note:
    Deleting the file [http://kb.mozillazine.org/localstore.rdf localstore.rdf] will reset the customizations of the toolbars to the defaults.
    You can rename "localstore.rdf" to "localstore.rdf.sav" to test if that solves it.
    Then you can restore the customization by copying "localstore.rdf.sav" to "localstore.rdf" if it didn't work.

  • Sum Account based on first 3 Characters of member name

    In ASO I am trying to sum a group of accounts that all start with 460???_SUS. Any suggestions are appreciated.

    Try this
    WITH MEMBER [Market].[Sum Expense for States with New]
    AS
    'Sum
    (Filter([Market].Levels(0).members, ISMATCH([Market].CurrentMember.MEMBER_NAME, "New")),
      [Measures].[Total Expenses]
    SELECT
    {[Measures].[Total Expenses]}
    ON COLUMNS,
      {Filter([Market].Levels(0).members, ISMATCH([Market].CurrentMember.MEMBER_NAME, "New")),
      [Market].[Sum Expense for States with New]}
    ON ROWS
    FROM
    Sample.Basic
    WHERE ([Scenario].[Actual])This gives
    (New York)     8914
    (New Hampshire)     3337
    (New Mexico)     3659
    (Sum Expense for States with New)     15910
    Regards
    Celvin
    http://www.orahyplabs.com

  • Publishing bug with FTP servers - Spaces at end of file/folder names

    I'm sharing what I've found after lots of troubleshooting with my Mom's iWeb website. I originally came across this in the previous version of iWeb, and have seen it again in the current version.
    For the sake of this example, she had an image gallery on her site. The image file she added to iWeb had a space at the of the filename, just before the file extension, something like "image name .jpg"
    In the old version of iWeb (iWeb 08), we would publish the site to a folder on her computer, and it would generate a folder for each image in the gallery. These folders would hold the original image and thumbnail image. Each folder name was the image's filename, minus the extension. In this example, the folder name was "image name " with a space at the end, which is valid on the Mac OS X file system.
    When we uploaded it to the FTP site (which happened to be GoDaddy) using a 3rd party FTP tool, certain images would always fail to upload. After much testing and troubleshooting with other FTP software, we found that the FTP server did not allow spaces at the end of folder names, and it automatically replaced them with underscores. So, we tried to upload a folder called "image name ", and ended up with one called "image name_". As a result, we couldn't upload any of the files that were supposed to be IN that folder, because it could not be found under it's intended name.
    Fast forward to today, using iWeb 09. Now the software allows you to upload to a 3rd party FTP server, so we've stopped using the other FTP software and do it all in iWeb.
    She added a new image to her gallery and tried to publish changes, and got the error: "There was an error communicating with the FTP server. Try again lager, or check with your service provider"
    Once she removed the image, publishing worked again. It turned out the original image had a space at the end of the filename, just before the extension again. Once this space was removed, everything worked again.
    Hopefully this helps somebody else down the road. If you have trouble with certain files, check them for spaces at the end, just before the extension. Perhaps in a future release, Apple could update the site publishing code to trim leading/trailing spaces from folder names.
    If you've seen this before, or have any further questions/feedback for me, feel free to post a response. Thank you for reading.

    It would be nice if Apple could make their error messages more descriptive of the actual problem so we have a better idea of how to solve it. I am "the mom" who had the problem B2Ben posted about.
    The error message seemed to place blame on the ftp server or my ISP, consequently I wasted a lot of time with these people when it wasn't even remotely their fault.
    As with most computer problems, I ended up learning a lot from it and it always helps with gaining confidence. This is my 20th year as a Mac user!.. yes, since 1989. I look forward to seeing what some of you have experienced with this same issue.
    iMac GHZ PowerPC G$ Mac OS X (10.5.7)

  • Prevent using special characters in file and folder names?

    I've recently begun adding windows clients to my network. In doing so, I've found that on my file shares from OS X server, the windows clients are unable to see files and folders which have names containing special characters such as / ? < > \ : * | ”
    Unfortunately my accounting department has been creating files with these characters in their names for several years. I would like to find if there is a way to prevent them from using a defined set of characters in the file and folder names to prevent them from "accidentally" doing so in the future.
    I've found that by turning off streams support on SMB in OS X server, that my windows clients can at least see that a file or folder should exist, albeit with a corrupted file name. Removing the special characters from these names allows the proper name to become visible and the file accessible.
    Any info would be greatly appreciated.

    (_seb_) wrote:
    > Gary White wrote:
    >> On Sun, 19 Nov 2006 19:15:04 +0100, "(_seb_)"
    <[email protected]> wrote:
    >>
    >>> "ça alors: it's a déjà-vu"
    >>>
    >>> How can I encode this so it's valid as a
    directory name, yet can be
    >>> displayed as intended when the name is output to
    the page.
    >>> urlencode() does not do the job, neither does
    htmlentities()...
    >>
    >>
    >> What's wrong with:
    >>
    >> $l="ça alors: it's a déjà-vu";
    >> print urlencode($l)."<br>\n";
    >> print htmlspecialchars($l);
    >>
    >> Gary
    >
    >
    > I know that, but what is the name of the directory? It
    has to be a real
    > directory name, not a string stored somewhere.
    >
    > What's a valid encoding for a directory named "ça
    alors: it's a
    > déjà-vu"? I can call a folder like this on my
    Mac, but it won't work on
    > any server...
    >
    >
    >
    PS: basically it's not a url encoding issue.
    I can url encode "ça alors: it's a déjà-vu",
    and pass it in a url query string. But my issue is not
    with an url query string, it's with an actual URL, that is,
    the actual name of the directory. It
    can't be "ça alors: it's a déjà-vu". But I
    want to allow the user to name their directory like that
    if they want. So I need a way to encode this into characters
    that can be used for an actual
    directory on the server.
    seb ( [email protected])
    http://webtrans1.com | high-end web
    design
    Downloads: Slide Show, Directory Browser, Mailing List

Maybe you are looking for

  • Creative alchemy and counterstrike

    Does anyone use alchemy for counterstrike .6. I just got a new pc and it came with Vista premium 32 and a creative xfi xreme gamer card. The problem im having is hearing like i did on my old computer and xp with soundblaster augdio 2. Im having a har

  • Changing fill colour for partly transparent images

    Does anyone know how to change the fill colour used for partly transparent images? I have a bunch of PNGs that I made for use as clip art, which I imported into iPhoto (that way I can use the media browser with Pages and Keynote). Unfortunately, the

  • Duplicate camera RAW Files

    Two questions. Is the any way to tell which version of camera RAW is installed other than looking at the "calibrate" tab. My "calibrate" tab shows ACR 3.6 but I am fairly sure that I have 3.7 installed as on the "adjust" tab, Auto/Default controls ar

  • Battery Enquiry on Macbook Pro

    My wife wants to purchase a new Macbook Pro 15 inch. She was impressed by the new "green" battery. Her question is how long does the new battery last? Is the time frame 1 year or more? Also, since it's an internal battery and can't be taken out by us

  • Help! Could not startup the upgrade program

    Hi, I am trying to upgrade my BWQ system and when I tried to start up the upgrade program and I got following errors: D:\Download\Upgrade\BS2008UpgMaster_51035701>startup.bat "jce_policy_zip=D:\Down load\jce_policy-1_4_2.zip" Installing runtime D:\Do