Script/Automator Get Filenames in Folder and Move Each File into Folder based on Filename?

I have searched for an answer to this and I have searched through multiple file renaming apps on the app store too but alas I cannot find anything that does what I want so I ended up looking into Automator as my saviour but I am a total NOOB.
What I want to do is point automator to a folder of my choosing
Automator then takes each file in that folder and creates a folder with the same name as the file and then move the file into that subfolder.
Sounds easy enough eh
I'm totally stumped, anyone have any guidance ???

This is a PITA to do in automator - automator does not handle loops the way it should - but in applescript it looks like so (open this in the applescript editor, select the file you want to run it on in the Finder, then run the script):
tell application "Finder"
          set mainFolders to the selection
  -- selection returns as a list, so even if there's only one folder a loop is used
          repeat with thisFolder in mainFolders
  --get the folder's contents
                    set containedItems to every item of thisFolder
                    repeat with thisItem in containedItems
  -- get name of file, add 'ƒ' to avoid name conflicts
                              set newFolderName to (displayed name of thisItem) & " ƒ"
  --make folder, move item
                              set newFolder to make new folder at thisFolder with properties {name:newFolderName}
  move thisItem to newFolder
                    end repeat
          end repeat
end tell

Similar Messages

  • Unix Script to connect to Portal Database and move the files to XI Server

    Hi all,
    we have a requirement where the source BW system is placing files in Content Management in the link http://xxx:50100/irj/go/km/docs/documents/Public%20Documents/HFM.
    XI needs to read the files from the above location.Since the files are stored in Portal database,we cant do FTP to this location.
    So we have been asked to write a script which connect to this location and moves the files to XI directory.
    Can someone plz help me with this script?

    The concern has been discussed earlier at
    here and should be helpful to check the database size and free available space in exchange server.
    This blog has also good explained about "how to count mailbox per database in exchange 2010". Please check this :
    http://blog.powershell.no/2010/11/21/retrieve-number-of-mailboxes-per-database-in-exchange-server-2010/

  • Trying to create an Applecreate to rename files into folders based on filename

    I am trying to create an AppleScript that will take a file (a.b.c.txt forexample) and create a directory from the filename minusextensionand then move the file into that directory
    ie.a.b.c>a.b.c.txt
    I found this script from red_menace
    {input, parameters} -- create folders from file names and move
      set output to {} -- this will be a list of the moved files
      repeat with anItem in the input -- step through each item in the input
        set {theContainer, theName, theExtension} to (getTheNames from anItem)
        try
          set destination to (makeNewFolder for theName at theContainer)
          tell application "Finder"
            move anItem to destination
            set the end of the output to the result as alias -- success
          end tell
        on error errorMessage -- duplicate name, permissions, etc
          log errorMessage
          # handle errors if desired - just skip for now
        end try
      end repeat
      return the output -- pass on the results to following actions
    end run
    to getTheNames from someItem -- get a container, name, and extension from a file item
      tell application "System Events" to tell disk item (someItem as text)
        set theContainer to the path of the container
        set {theName, theExtension} to {name, name extension}
      end tell
      if theExtension is not "" then
        set theName to text 1 thru -((count theExtension) + 2) of theName -- just the name part
        set theExtension to "." & theExtension
      end if
      return {theContainer, theName, theExtension}
    end getTheNames
    to makeNewFolder for theChild at theParent -- make a new child folder at the parent location if it doesn't already exist
      set theParent to theParent as text
      if theParent begins with "/" then set theParent to theParent as POSIX file as text
      try
        return (theParent & theChild) as alias
      on error errorMessage -- no folder
        log errorMessage
        tell application "Finder" to make new folder at theParent with properties {name:theChild}
        return the result as alias
      end try
    end makeNewFolder
    But my problem with this script is that it does messes up if the file name includes the period, from my example, the listed script will make directorys a, b, and c instead of a.b.c

    You can use this Automator Workflow:
    for f in "$@"
    do
      d=${f%.*}
      if [ ! -d "$d" ]; then 
           mkdir "$d"
      fi
      mv "$f" "$d"
    done

  • Create folder and move files to specific directory in AL11

    My requirement is to create a new folder in one of the existing directories in AL11 and move some files into it.
    I searched the forum and found this solution but it creates folder only in DIR_HOME directory.
    data: unixcom like rlgrap-filename.
    data: begin of tabl occurs 500,
    line(400),
    end of tabl.
    unixcom = 'mkdir mydir'. "command to create dir
    "to execute the unix command
    call 'SYSTEM' id 'COMMAND' field unixcom
    id 'TAB' field tabl[].
    I want the folder to be created in some other directory DIR_INTERFACES .
    Any suggestions are welcome ..

    Get complete path (physical path) using FM FILE_GET_NAME_USING_PATH.
    Default directory is DIR_HOME, hence it creates file in that directory...If you specify complete folder name, it will be created under that path..
    Concatenate mkdir
    space
    <physical path>
    mydir
    into unixcom.

  • How do I move a file into a folder on my creative cloud site?

    While Im on my creative cloud site, trying to organize files... how can i simply move an old file/doc into a folder that I've already created??
    Also, on creative cloud I want to view actual print size without downloading it somewhere... can I????

    To move an individual file from the Grid View click on the triangle in the bottom right and choose Move. You can then choose which folder to move the file into.
    To move multiple files at once switch to the List View. Check the files you want to move and from the blue menu at the top choose Move.

  • Move files into folders based on EXIF Creation Date

    Hi all,
    Being a novice with Applescript I have read what I can find on this forum, but are not able to find exactly what I'm looking for. I think that the posting "Using AppleScript to create folders and place files in them" is the closest I get to what I want but I want to create the folders based on EXIF creation date.
    Let me explain.
    I have a folder that contains thousands of jpg, mp4, mov and avi files; all created by different cameras. I want to bring some order to this and place files in folders based on year, month and date that the file was created (the photo taken or the video captured). This date is stored in the EXIF creation date.
         Take all files in folder A
          foreach file find the EXIF creation date
          move each file into directory tree (at same location is ok) where toplevel is YEAR, next directory level is named accoring to EXIF creation date as MMDDYY
          if no EXIF creation date can be found, fallback to creation date (file property?)
          if no good date is found, leave file alone in folder A for manual sorting; do not use modification date as this may have been altered
         this would create a structure as
         2002
                011602
                        File 1 taken Jan 16 2002
                        File 2 taken Jan 16 2002
                082002
                        File 1 taken Aug 20 2002
                        File 2 taken Aug 20 2002
          2003
                 etc 
         2004
             |   etc
         2014
                 010114
                        File 1 taken Jan 1 2014
    etc etc

    Well, technically that's correct, Frank, but the same could be said of much of AppleScript - the core functionality is limited, but there's a lot you can do.
    For example, it's actually trivial to use Image Events get any given EXIF tag of an image:
    set theFile to (choose file)
    tell application "Image Events"
              set f to open theFile
              set cD to value of metadata tag "CreationDate" of f
      close f
    end tell
    Now, cD will have the value of the CreationDate tag (assuming it exists, of course - you'll need to wrap this in a try/end try statement). Once you have that it shouldn't be too hard to extract the date components, work out the target directory name and move the file.

  • I have files in my iTunes media folder that somehow are not in my library. How do I get iTunes to scan my media folder and add missing files to my library without making a copy of each file in the same location?

    I have files in my iTunes media folder that somehow are not in my library. How do I get iTunes to scan my media folder and add missing files to my library without making a copy of each file in the same location? If I use add file / folder to library, it scans the folder and then makes a copy of any file that is not in my library in the exact same location; I recal in older versions of iTunes being able to just drag my media folder into my library and it would update missing links.

    Only the songs that are connected to iTunes will be copied when you consolidate to a new folder.
    Splitting the media folder away from the usual location makes it harder to move iTunes in the future.
    Are you go move everything back once you've tidied up or are you going to leave it that way? Either way I'd recommend you create an iTunes folder at the new location, an iTunes Media folder inside that, and consolidate to this new iTunes Media folder. You should also use the option File > LIbrary > Organize Library > Rearrange files in the folder "<Media Folder"> if you have not already done so.
    tt2

  • Script to find certain sized messages a move them to a folder.

    We are preparing to move our organization to Exchange Online.    Because of this we have an issue that no message in any mailbox can be > 25MB.   Management wants a script to parse every user's mailbox to find messages that are
    > 25MB and put them in a folder in that mailbox called 'Large Items' so that the end users can deal with them on their own.
    I am unable to find any script that will go through EVERY user's mailbox and make this folder and move items into it.   Has anyone else done this?

    Hi
    Yes, there is no script or command could do that.
    The most closest command should be Search-mailbox
    Search-mailbox can search messages in a specified mailbox and copy message to a specified target mailbox, but it may not search the message based on message size.
    Cheers
    Zi Feng
    TechNet Community Support

  • I have started Family Share and ever since I activated my iTunes Match none of my family members get the iTunes purchases and movies???

    I have started Family Share and ever since I activated my iTunes Match none of my family members get the iTunes purchases and movies???

    Hi Daddy DooL, 
    Thank you for participating in the Apple Support Communities. 
    If you or your family members using Family Sharing can see shared purchases, start with the troubleshooting steps from this article on the affected devices:
    If you don't see your family's shared content - Apple Support
    Best Regards,
    Jeremy 

  • In my RH8 project, I have a disappearing folder and one, un-removeable, permanent folder ???

    I am using RH8 with both updates installed on a Win XP system.  As you might know from my other postings, ignorance (my own and mine alone) has caused several problems for me.  I did not know that the folders in the RH Project Manager were pseudo-folders.
    Okay, here's what I did first and I think I understand what RH did in response.  I wanted to create separate folders for each major sub-division in the Help project and segregate the images for those topics, also.  I tried creating a "subdiv_1_topics" folder with a "subdiv_1_images" folder as a subfolder.
    I could not get RH to generate WebHelp with any files in these sub-topic and sub-sub-image folders.
    I tried to return to the "status quo" by deleting the folders I had created.  However, I have never been able to delete one of the image folders.  It is nested in the RH Images folder but my images folder (lower case i) is now the MAIN images folder.
    I learned about this, the very hardest way.  I discovered that I could move image files, one-at-a-time, from my images folder up to the RH Images folder.  I thought I was putting the images back where they belonged but I was wrong.
    On my local drive, RH was moving each image out of the Images folder and was putting it into the root with all the topic htm files and RH files. I did not notice this and I went completely through the WebHelp generation process and our process of moving the generated files from the WebHelp folder to our SVN repository.  Then, I left for the evening.
    Next morning, first thing, my boss and I were both apoplectic when we discover that all of the images are gone from the Help topics. A quick check of Windows Explorer and the RH folder/file explorer showed what had happened.  I spend the next 3 hours moving all the images, one-at-a-time, from the topics area back to my images folder under the RH Images folder.
    I have left them alone since ... NOW, the NEW EVENT:  I wanted to create a folder just for a few topics that had been prepared in advance for future application enhancements.  I was going to ask this forum if there was a way to block RH8 from touching that folder when I generated WebHelp ... I noticed a dfferent problem.  The folder that I created is gone from RH but in the right place in Windows Explorer.  I am baffled.  In summary, in a perfect world, I would have the RH HTML Files (Topics) folder with just the HTM files and all the attending RH files.  Then, as either a sub-folder to the topics folder, or as an equal folder, I would like a place to put these several files for future use, with the folder protected from WebHelp generation until I say so.  This is just for convenience.  Then, I would like to have the RH Images folder with all the project images but no sub-folder where the images lie right now.
    Feel free to contact me off this forum.  Sorry, if I am too breezy here.

    Sorry Ernie that wasnt the problem, i highlight the folder and REBUILD is greyed out
    I highlight INBOX and select REBUILD it does something to INBOX and APPLE HOT NEWS folders, but does nothing to any of the  other folders.
    yeah, that is the only folder with a problem.
    getting a little frustrated now, i created another "mailbox" inside that Mailbox/folder and of course the little triangle displays the new folder when turned one way and hides it when turned the other way.
    it seems as if i accidentally at an earlier time i created a new folder inside this folder and deleted it, possibly with the emails still it, and it hasnt updated the number of unread emails LOL.
    i reckon i will just delete the darned thing all together and get on with life without any emails from "jeanie jeanie", i havent heard from her for ages anyways.
    tim

  • I have tried to download Mavericks on my 2010 iMac(10.6.8), but nothing happens, not even the install app downloads, also I tried to download chrome, I moved it to the applications folder and when I opened the folder it wasn't there

    I have tried to download Mavericks on my 2010 iMac(10.6.8), but nothing happens, not even the install app downloads, also I tried to download chrome, I moved it to the applications folder and when I opened the folder it wasn't there. I have a 1tb hard drive that is mostly empty. By the way I just got this imac used from a reseller.

    Mavericks downloads into the Applications folder, where you can install it.   Some Mac App Store Troubleshooting information and how to resume a download that was interrupted; some of the information here might get you an answer.   Failing that, try contacting Apple Support.

  • Cannot move any files into trash to delete them. I get a Trash warning box saying "The Finder cannot complete the operation because some data in 'file name' could not be read or written.(Error code - 36)".Macbook has so much data it is almost not working

    Cannot move any files into trash to delete them. I get a Trash warning box saying "The Finder cannot complete the operation because some data in 'file name' could not be read or written.(Error code - 36)".Macbook has so much data it is almost not working.
    I have tried reseting to factory settings by removing battery and holding down the power switch for more than 5 sec but this does nothing.
    Any ideas would be greatly appreciated as I think with so much unwanted data on the desktop and other places the whole os will crash very soon.
    Thanks, Rick

    The hard drive may be dying anyway, or the directory damaged because it is so full.  You should never let the hard drive get over 85% full.
    A -36 error is a read/write error.
    All you did with the power is reset the SMC.  Does nothing to reset everything to factory settings. 
    Do you have your original 10.4 installer discs for the MacBook?
    Is your data backed up?

  • Some Virus Files that been created inside the Windows system file folder and System32 sytem file folder

    I have here some copies of the files that I have retrieve inside the Windows folder and System32 system file folder. This files was created by a virus or some malware of some sort. Please take a closer look at thsi becasue this virus doesnt have a visible
    events or something that you see at your screen to get you worried or to let you know that there is something bad happening on your system. I just cant get a copy of the virus file that is in a usb or a mass storage device of many students here in my internet
    shop. And I'm worried even thou it does not do anything visible, I'm worried that it might made some security holes or privacy leaks that I can't seem to see it. Can't find the main program if it has one, because deleting the files seems to work but if my
    computer plugs an infected usb device again the files comes back even thou the main virus file inside the usb device has been block and deleted by Avast, the files still is being created by some program of some sort inside the system, maybe it is already inside
    the system or maybe not because the files will only be created if an infected usb device has been plug in even thou Avast has already detected the main .fat file inside the usb device still the files are created. I'm guessing this virus didn't penetrate the
    system because full system scan came out clean twice. Boot time scan and start-up scan all users and all loaded to memory files also came out clean, but the files was already deleted before the scan so I don't know for sure of the result if these files were
    scan. I just want to know why these files penetrated the Windows system folder even if my UAC is active, how come this virus has gain access to the system folder and bypassing the UAC, DEP and my Windows Defender. And also I'm gonna post in Avast forums about
    this too.
    My Unit:
    OS: Windows 7  Ultimate SP1
    MOBO: Gigabyte G41M COMBO
    CPU: Pentium(R) Dual-Core E5800 @3.20ghz x2
    RAM: 2.00gb
    System Type: 32 Bit
    http://www.mediafire.com/download/41lercy9xdzn3wq/Windows.rar

    Not really relevant to DPM, I'd suggest you post over at
    http://social.technet.microsoft.com/Forums/en-US/home?forum=w7itprosecurity

  • I backup my iphone on my pc and copy backup file into drive D then i setup new OS on my pc. after that i copy the backup file into itunes backup folder but itunes can't find the backup file to restore my iphone. how can i restore my iphone?

    i backup my iphone on my pc and copy backup file into drive D then i setup new OS on my pc. after that i copy the backup file into itunes backup folder but itunes can't find the backup file to restore my iphone. how can i restore my iphone?

    Don't you just love changes in interfaces?
    I found the answer to my question.
    When you attach a device (iPhone, iPad) to your Mac, in iTunes 12 in appears as a tiny icon in the second "row" of the iTunes display. Click the icon and the familiar iTunes display for the device appears. From there, on the Summary screen, you can see the dates of the backups of the device (iCloud and backup to the computer). You can also use the button to backup to the computer.

  • Urgent help needed - new to Macs, accidently cut and paste over top of photo folder and now no sign of folder or file, no auto back-up in place, how can I restore photos pls

    Urgent help needed - new to Macs, accidently cut and paste over top of photo folder and now no sign of folder or file, no auto back-up in place, how can I restore photos pls

    Thanks for prompt reply, yes we have tried that but have now closed down the browser we where the photos were.
    We haven't sent up time machine, do you know whether there is any roll-back function on a Mac?
    Thanks

Maybe you are looking for

  • Switching off 8520 (Full off or Sleep mode?)

    Hi, Are these 2 different 'types' of switching off? When I press the right hand RED power key, I get the following: TURNING HANHELD OFF - press any key to abort then TURNING HANDHELD OFF If after a minute or so I move and accidentally catch the power

  • I have a question about exporting a short movie to burn on a DVD.

    Ok, it's me again.  You guys were so much help last night, that I am back for another piece of advice.  I have made a short 23 minute movie in Premiere Pro CS3, using 200 still images and some music.  I realize that this program is way more than I ne

  • Need "Next Page" keyboard command--Word, Macbook Air

    Is there a keyboard command that will take me to the top of the next page in Word 2011 on a MacBook Air?  I can creep up and down the existing page using Fn + right/left arrows.  I can go to the top and bottom of the file using Fn + Command + left/ri

  • DHCP server application for Snow Leopard

    Hey Guys, is there any DHCP server application for SL? Want to share the Internet through my laptop and to set up IPs manually. Thanks in advance

  • Lock in lock manager could not be set - long text

    Hi Experts, We have a issue with the 124002 ID request for the ODS ZSDOD005 (request number REQU_6ROBVFEQ9SSOIJY5MDF2W9BTX). It has green status, but if you open the monitor, the status is red. If you search for more detail,  you can see the followin