Automate Creation of Folder based on Filename

Hi,
I am a total newbie to Automator, and although I have some programming background, I have not wrapped my brain around how this wonderful tool works yet. I need to perform a task on several hundred files and I need to do it soon, so no time to learn and play with Automator right now.
I was wondering if someone can give me a true step by step instructions for creating a script that will do the following:
This is how I would like the flow to behave:
1. I select a file and run the script (hopefully based on a keystroke). The script will then:
2. Create a new folder in the same directory as the file.
3. Name the new folder based on the filename (minus the extension) of the above selected file.
4. Move the selected file into the new folder.
So basically I am enveloping the selected file in a new folder that is named the same as the file itself (minus the extension).
Thank you in advance.

OK, I reworked and tested it, so I think I've got all the oddities found. I wound up just using an AppleScript, since about the only thing Automator was used for was getting Finder Items (and it didn't do so well at that). Paste the script into the Script Editor and save it as an application (make sure the Startup Screen option is unchecked). You can either drop items on it or double-click it, in which case it will prompt for items. Document files are the only things processed, and packages/bundles are handled correctly (getting subfolders will not go into them), so you don't have to worry about things like application bundles and .rtfd files.
<pre style="
font-family: Monaco, 'Courier New', Courier, monospace;
font-size: 10px;
margin: 0px;
padding: 5px;
border: 1px solid #000000;
width: 720px; height: 340px;
color: #000000;
background-color: #FFDDFF;
overflow: auto;"
title="this text can be pasted into the Script Editor">
-- make new folders with the name of document files, then move them into their respective new folders
-- the following properties affect the operation of the script
property GetFiles : false -- get individual files?  true chooses files, false chooses folders
property GetSubFolders : true -- get contents of subfolders?  true gets contents of subfolders, false skips them
property DestinationFolder : "" -- if a folder path is specified, it is used as the destination for file moves
on run -- application double-clicked
if GetFiles then
choose file with prompt "Choose a file:" default location (path to desktop) with multiple selections allowed without invisibles
else
choose folder with prompt "Choose a folder:" default location (path to desktop) with multiple selections allowed without invisibles
end if
open the result
end run
on open TheItems -- items dropped onto the application
if DestinationFolder is not missing value then try -- verify destination path
DestinationFolder as alias
on error
set DestinationFolder to (choose folder with prompt "Invalid destination folder path - where do you want to move the items?")
end try
set SkippedItems to {} -- this will be a list of skipped items (errors)
set TheFiles to {} -- this will be a list of items to process
repeat with AnItem in TheItems -- expand folders
set AnItem to the contents of AnItem
set FileInfo to (info for AnItem)
if (folder of FileInfo) and not (package folder of FileInfo) then -- a folder
if GetSubFolders then
repeat with SubItem in (ListFiles from AnItem)
set the end of TheFiles to (contents of SubItem)
end repeat
else
tell application "Finder" to (get files of AnItem) as alias list
set TheFiles to TheFiles & the result
end if
else
set the end of TheFiles to AnItem
end if
end repeat
repeat with MyFile in TheFiles -- do stuff with the resulting items
set {TheClass, TheName, TheExtension, TheContainer} to (GetTheNames from MyFile)
if TheClass is «class docf» then try -- just document files
tell application "Finder"
if DestinationFolder is not missing value then
make new folder at DestinationFolder with properties {name:TheName}
else
make new folder at TheContainer with properties {name:TheName}
end if
move MyFile to the result
end tell
on error ErrorMessage -- the folder already exists, permissions, etc
log ErrorMessage
set the end of SkippedItems to (TheName & TheExtension)
-- set the end of SkippedItems to (AnItem as text) -- the full file path
end try
end repeat
if SkippedItems is not {} then -- handle skipped items
set AlertText to "Error with moving files to folders"
if (count SkippedItems) is greater than 1 then
set TheMessage to ((count SkippedItems) as text) & space & "items were skipped:"
else
set TheMessage to "1 " & "item was skipped:"
end if
set {TempTID, AppleScript's text item delimiters} to {AppleScript's text item delimiters, return}
set {SkippedItems, AppleScript's text item delimiters} to {SkippedItems as text, TempTID}
display alert AlertText message TheMessage & return & SkippedItems
end if
end open
to GetTheNames from SomeFile
get a class, name, extension, and container from a file path
parameters - SomeFile [mixed]: a file path
returns [list] - item 1 [constant]: the class of the file object
item 2 [text]: the name of the file
        item 3 [text]: the .extension (if no extension, the value returned is "")
item 4 [alias]: the containing folder of the file
set SomeFile to SomeFile as alias -- the Finder likes aliases
tell application "Finder"
set TheClass to class of (get properties of SomeFile)
set TheName to name of SomeFile
set TheExtension to name extension of SomeFile
if TheExtension is in {missing value, ""} then
set TheExtension to ""
else
set TheExtension to "." & TheExtension
end if
set TheName to text 1 thru -((count TheExtension) + 1) of TheName -- just the name part
set TheContainer to (container of SomeFile) as alias
end tell
return {TheClass, TheName, TheExtension, TheContainer}
end GetTheNames
to ListFiles from SomeItem
return a list of files contained in SomeItem, drilling down into subfolders (not packages)
parameters - SomeItem [mixed]: the item to get the contents of
  returns [list]: a list of aliases
set {FilesList, SomeItem} to {{}, SomeItem as text}
set FileInfo to (info for SomeItem as alias)
if (folder of FileInfo) and not (package folder of FileInfo) then -- a folder
try
tell application "Finder" to set SubItems to (items of folder SomeItem)
on error
return {}
end try
repeat with AnItem in SubItems -- drill down
set FilesList to FilesList & (ListFiles from AnItem)
end repeat
else
set the end of FilesList to (SomeItem as alias)
end if
return FilesList
end ListFiles
</pre>

Similar Messages

  • 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

  • FTP Transfer: based on filename it needs to be moved to different directory

    Hi,
    I am doing a FTP transfer of file from one location to another. In this scenario, based on filename the file needs to be moved to Directory A or Directory B.
    Is this possible having a single receiver file adapter?
    Regards,
    Ashish

    Hi Ashish
    What you can do is
    1. You can pick the file from location and use variable substitution to deliver the file on base of filename. But the limitation is folder name should have some characters common to filename as well.
    2. You can write file to a temperory location and then execute OS command to move the files to appropriate folders
    3. Create two communication channels and enhanced receiver determination to find our which folder based on filename at runtime.
    Thanks
    Gaurav

  • OutLook 2007 Macro to create Folder Based on Received Date

    Dear All,
    Is it possible to create a macro which will automatically create a folder based on Received Date of the mail and then group these mails (in folders) based on the received month….
    Can someone help me with the VBA Coding for Outlook 2007, where I select a folder and the macro creates folder’s and subfolder based on the received month and date-wise folder (based on the received date of the mail).
    Thanks...

    Yes, it is possible, but why would you want to split up your emails like that?
    Note that you can also do a simply search query to find all emails received within a certain month. For instance, when you want to see all emails which you received in July 2013 type the following in the Search Field:
    received:(July 2013)
    For more information about using Search within Outlook see:
    http://www.howto-outlook.com/howto/searchcommands.htm
    Robert Sparnaaij
    [MVP-Outlook]
    Outlook guides and more: HowTo-Outlook.com
    Outlook Quick Tips: MSOutlook.info

  • How to automate layer stack creation including layer masks based on filename?

    Hi
    Can someone help me to create a script that would automate the creation of layers including a layermask, based on filenames.
    E.g.
    Unwrap_001_diffuse.jpg
    Unwrap_001_mask.jpg
    Unwrap_002_diffuse.jpg
    Unwrap_002_mask.jpg
    The image with the suffix "_diffuse" would be the layer and the image with the suffix "_mask" would be the layermask.
    In the above example the script would create 1 psd with 2 layers.
    If there is no file with the ending "_mask", the script would only create a single layer with no layermask.
    Any help would be highly appreciated.
    Thank you
    Boris
    I

    For starters the Folder-selection dialog could be used if the images are all in one Folder.
    var theFolder = Folder.selectDialog ("select folder");
    And then the method getFiles could be used to get the files.
    var theFiles1 = theFolder.getFiles("*_diffuse.jpg");
    Loading the file as Layers can be done with the ScriptingListener code for File > Place for example and finding the corresponding mask files seems fairly easy.
    Are they grayscale or RGB?
    But why jpg anyway?
    Are those renderings?
    If so why not tiffs or some other non destructively compressed file format?

  • Automatic rights at folder creation

    Hello all: I am debating having my user profiles be written onto an NSS volume. Can I setup a folder that would allow a user to automatically create a folder for their profile for which only they have rights? Or am I stuck pre-creating the folders and setting the rights? If I give everyone full access to a specific folder, then they can automatically create the folders BUT everyone has full rights.
    Doable? Thanks, Chris.

    Thanks, Chris.
    >>> mdallair<[email protected]> 2/2/2015 4:16 PM >>>
    cmosentine;2345930 Wrote:
    > Hello all: I am debating having my user profiles be written onto an NSS
    > volume. Can I setup a folder that would allow a user to automatically
    > create a folder for their profile for which only they have rights? Or
    > am I stuck pre-creating the folders and setting the rights? If I give
    > everyone full access to a specific folder, then they can automatically
    > create the folders BUT everyone has full rights.
    >
    >
    >
    > Doable? Thanks, Chris.
    The only product i know that can do that is Novell Storage Manager
    Martin Dallaire
    mdallair
    mdallair's Profile: https://forums.novell.com/member.php?userid=3076
    View this thread: https://forums.novell.com/showthread.php?t=481632

  • How can I automate creation of various thumbnails of an image with different filenames?

    I load an image, SampleA.jpg.  I want to automate creation of different sized thumbnails, one that is 640x360 and called SampleA iStock.jpg, and one that is 360x203 and called SampleA Revostock.jpg.  I want these files to be stored in the same directory as the source image.
    To my knowledge actions cannot do this because they hardwire the directory used when recording the action.
    I've also looked into scripts and batch processing and can't figure out how they can accomplish this.
    If anyone could list a simple step by step instruction how I can do this I would be very appreciative!

    I would recommend you post on the Photoshop Scripting Forum when you have questions regarding Photoshop Scripting.
    http://forums.adobe.com/community/photoshop/photoshop_scripting?view=discussions

  • Automatic Creation and Confirmation of Warehouse Task in EWM 5.1

    Hello,
    We want an automatic creation and confirmation of the warehouse task in EWM 5.1 on the based of a delivery type and warehouse number.
    The scenario goes in this way... As soon as the inbound delivery is created/replicated in EWM, the creation and confimartion of warehouse request, warehouse task and warehouse order (all the transactions) should be called automatically. And the goods receipt should be posted.
    Can someone throw more light on the customizing/BADI/enhancements etc required??
    Thanks and Regards..

    Hi koen,
    I tried with the FM that you suggested...
    But somehow with the process type 'stock removal' gives an error...
    Is that that this FM will help to create a pick task for a particular outbound delivery--Tcode:/SCWM/TODLV_TO.
    how will this FM take the outbound delivery as an input?or it will be on the corresponding sales order number and item number as input?
    Being new EWM i require help on this..about how to go about creating the pick task for an outbound delivery which wil be equal to the warehouse request.
    Thanks in advance,
    Rashmi.

  • Automatic creation of Inbound deliveries per HU

    Hi Guys
    I am looking for any information on how to automatically create inbound deliveries based on Handling units.
    The process is
    Create PO
    Receive ASN with packing details (e.g. one box = i HU)
    Auto creation of one Inbound delivery per HU
    Any assistance would be appreciated.
    Cheers

    Steve
    I don't know how you figured out it was me.
    The answer you have given believe it or not was what I was expecting as I thought it would need development.
    As for the value of this the logistics service provider believe that they can control the out away better with one ID per HU per box etc and also we are putting away in WM first and then 'post goods receipt' to update IM. We have a bespoke transaction where they scan the barcodes from the putaway tags in to a copy of LT11 and they can scan up to 100 lines and then save. When the save is activated the transaction checks first how many Transfer order/Lines are on each inbound and then are all of them confirmed when eventually the answer is Yes the system will then go to the Inbound delivery and post goods receipt automatically.
    This is so that the Sales office does not see the stock until it is located as backorder processing runs regularly and we do not want orders and deliveries appearing whilst the putaway process is being carried out, However they do want the stock available ASAP. Therefore it is better for them to have the HU-ID as one to one so that in theory materials become available quicker as if one ID had say 100 materials on it none of them would be available until the last one was put away and confirmed.
    I hope this explains it and thanks for your assistance.

  • Automatic creation of SES

    our company uses CATT for validating timesheet but we often have delays in the creation of SES based on the time entered.
    is there a way to automatically generate a SES based on time entered in CATT?
    and, if not, is there a way we can generate an invoice before the SES has been created/accepted?
    thanks
    Alisa

    marked by error

  • Automatic creation of Vendor in FI from Business Partner

    Hi, experts!
    We are looking into a process to automate the creation of vendor master data in FI Accounts Payable for our employees and to keep them in sync as employees' names, banking and address info change over time. We use concurrent employment, and we noticed that running PRAA as a mass-update job to create vendor records for all employees will create duplicate Vendors for employees who have more than one active Personnel Assignment.
    We are now looking into the possibility of using the Business Partner as a means of pushing HR data into FI within the same ECC6 system. So far, we have been able to turn on the automatic creation of BPs when new employees are 'hired' into our test system via transaction PA40. We can also use the program HRALXSYNC to create the BP for existing employees. Once these BPs are created, master data updates flow from the employee master data in HR to the BP. However, we can't seem to get the system to automatically create a Vendor record for this BP and have that linked together at the same time.
    Is this possible? If not, is there a transaction that can be run to do a mass creation of Vendor records for Business Partners that don't already have one?
    I can see that our BPs have been assigned to the proper Role in table BUT100, and we have "define(d) vendor link for business partner roles" in V_TBC002 to be "vendor-based". What configuration step might we be missing?

    Hi, Mahesh
    Thanks for the response!!  We have already created an entry in this table for Role Category = BUP003 (the SAP-delivered role category "Employee").  In this table, we have chosen the "Vendor Based" radio button, since we want Vendor master data to be created for all BUP003 business partners that are created.
    Which function modules need to be activated via the SPRO path Cross-Application Components -> SAP Business Partner -> Data Distribution -> Activate Function Modules in order to have Vendors automatically created whenever a specific role of BP is created?
    Thanks again for all your help!
    - Steve Miller

  • BAdi - Automatic Creation of Transaction Type (Activities/Tasks)

    Dear Experts,
    we have a customer requirement to create automatically Activities/Tasks if a certain date is reached. The user just want to receive a alarm/note when there is a created acitivitie.
    Which BAdi we casn use for the automatic creation of activities? Which options we have to do that?
    Relevant tables are CRMD_ORDERADM_H and CRMD_ACTIVITY_H as I know.
    Note: We can no use the visit plan.
    Best Regards
    Oliver Schultze

    Hi Oliver,
    CRM_ORDER_MAINTAIN and CRM_ORDER_SAVE are the function modules to create and save a business transaction. As you have the requirement to create Activities, Arden has suggested these function modules(transaction SE37). Based on your business scenario, you can use these FMs in BADI implementations to achieve the functionality.
    Thanks,
    Priyanka

  • Automatic creation of Service Arrangements in SAP CRM 2007

    Dear all
    we're using SAP CRM Resource Planning with HCM integration, so get the Employee Master and requried Availability Info Types replicated from HCM via ALE.
    Unfortunately, between the creation of an Employee and the Time Distribution, a Service Arrangement must be created manually. As both the HCM-side steps are executed automatically as background job, we are trying to find a way to also create Service Arrangements automatically. We do not need to maintain any data other than ID and Name for the Service Arrangement in the first place.
    Can you point me to a way to do this - eventually a function module that would be available for this purpose?
    Many thanks in advance!
    Christian

    Hi Christian,
    You need to do customization settings for automatic creation of Service Assignments. And for the same you need to do all these settings according to the SAP Help Document.
    You can have a look at the flow of the Service Assignment from the link below
    http://help.sap.com/saphelp_crm40/helpdata/en/c6/c14769c3fc814fbe3e5df8edcba791/frameset.htm
    You need to do the customizations from the sap help document. You can have a look from this link:
    http://help.sap.com/saphelp_crm40/helpdata/en/c6/c14769c3fc814fbe3e5df8edcba791/frameset.htm
    Technical Information : As Assignment functionality is based on WFM  Core, there are some BadI's exposed. You can implement them to achieve your functionality.
    Badi : CRM_SRV_SDL
    Implementation                                                     Purpose
    CRM_SRV_SDL_WFM                                         R/3 connection to the WFM Core
    CRM_SRV_SDL_RFC                                          TCP/IP connection to the SAP Business Connector when using the external   Scheduling Engine of a third party vendor.
    In our development scenario, we have used the BadI's CRM_SRV_SDL to achieve the functionality.
    Hope this helps.
    Thanks,
    Samantak.
    Edited by: Samantak Chatterjee on Sep 11, 2009 9:43 AM

  • Automatic creation of purchase info record

    Hi friends
    I could not find check box in RFQ (ME41!N)or in Quotation (ME47N) for updating/automatic creation of purchase info record.
    Thanks
    Sunny

    Hi,
    you can maintain the info update for the required quotation through ME47.choose the required line item and click on the "item detail" icon and put the necessary value for info update:
    1-     No update
    2-A     Update with or without plant
    3-B     Update with plant (if no plant ban)
    4-C     Update without plant (if no plant requirement)
    Indicator: Update Info Record
    Determines whether:
    The purchasing info record for this vendor and material is to refer to this PO item, and
    The item is to be valid for the entire purchasing organization or just for the plant.
    Use
    The indicator determines which prices and conditions are suggested in future PO items.
    Prices and conditions can apply to an entire purchasing organization or to a single plant within a purchasing organization.
    For example, if you create a purchase order for a plant for which an info record has been defined at plant level, the purchase order is based on the conditions in the plant info record and not on the conditions that apply to the purchasing organization.
    Procedure
    Enter the relevant plant key:
    A
    Updating of the document number is effected at plant level as long as there is a purchasing info record at plant level. Otherwise the document number is updated at purchasing organization level.
    B
    Updating is effected at plant level if plant conditions are allowed for the plant.
    C
    Updating is effected without plant data if plant conditions are not necessary for the plant.
    Dependencies
    The level at which updating of the document number may be effected is defined for each plant.
    Hope this will clarify your query.
    Thanks & Regards,
    Bijay Pradhan

  • Automatic creation of debit or credit memo

    Hi All,
    I have a requirement of automatic creation of credit note with reference to sales order when i click save at transaction VF01 after generating billing document against delivery number.
    I used the include ZXVVFU08  it is triggered when the save button is pressed in VF01. i have wriiten BDC code in this include. At the point when i click save, the billing number is getting generated but credit memo is not getting generate.It is giving an error 'No billing documents were generated'
    How do i ensure that the invoice number is already saved before the BDC starts?
    Need help. Thank you!

    Dear seetharamsapsd ,
    Create a new document type for both credit memo and debit memo requests.
    Copy control to the respective credit memo and debit memo should be there.
    Pricing procedure should contain provision to map the difference amount.
    Create  a Z program recording a BDC for the creation of Debit and credit memo request.
    It is better to keep have only one Z program.
    In the program write a logic to check the price change comparing the values of previous month created orders and
    this months condition record values.
    Based on whether there is increase or decrease , system should run the respective BDC for the debit or credit memo request.
    This program can be set in background maybe at midnight.
    Also save VF04 as a background job (so that the debit / credit memos as also created automatically)
    Set this VF04 background job to run after say 1 or 2 hours from the time our Z program is running.
    I hope you know the different tables/fields from where you can get the desired condition to run the program.
    Thanks & Regards,
    Hegal K Charles

Maybe you are looking for

  • Delivery cost for Stcok transfer through M.type : 351

    Hi Experts, Can anybody explain how to capture the delivery costs for Stock transfer through M.Type 351. Also kindly explain the steps involved in configuration of the same. Thanks in advance, Prabu

  • Out of memory when big files are being sent to N80...

    i downloaded a few big mp3 files (15-20mb) onto my 128 card i got with the phone, as soon as my new 2gb phone came, i didnt have a reader for my pc and my wife said she wanted these songs on her S.E.810i. i sent them over to her using bluetooth (with

  • Automatic picking of posting change delivery HTP

    Hello, We wanted to implement ARM. When we have follow-up activity as "Receive into plant" and Action "transfer to free available stock", delivery of type HTP gets created. As per standard, if we want to create automatic TO for picking of this delive

  • Can you explain me the loading process?

    This is my application: http://gazman.000space.com. If you will try to enter it now, you will see two loading bars one that is build in the application, that loading swf file, and one I made, that loading images that the application will use(I am jus

  • XSL disable-output-escaping problem

    When using the Java xslsample example to perform an XSLT transformation, we are trying to generate characters such as '<' in the output stream. However the following code fragment taken from the XSLT working draft: <xsl:text disable-output-escaping="