Applescript for creating job folders

having trouble with an applescript. I'm trying to create an applescript that will create a job folder for me with job number and job name in which I can include folders and subfolders.
I found this script by searching google and it's pretty much what I need (thank you to who ever might have created it). I altered the folder names to what I need, and it seems to work for the most part but throws an error at the end that says : Finder got an error: Can't make "drive:path" into type item
however it still makes everything i need. I would just like to get rid of the error.
the script editor highlights the line of text that's having issues for me, but since i barely knew what I was doing in the first place I don't know how or what to change.
if someone could help me that would be great. here is the code.
set thepath to {"drive:path"}
set JobName to text returned of (display dialog "Please enter Job Name:" default answer "Job Name")
set incomingDate to (current date)
set numYear to year of incomingDate as number
set textYear to text -2 through -1 of (numYear as string)
set JobNum to text returned of (display dialog "Please enter Job Number:" default answer {textYear & "xxx"})
set JobNumName to JobNum & "_" & JobName
set newsublist to {{"Builds", {"versions"}}, {"Links"}, {"Fonts"}, {"Proofs"}}
tell application "Finder"
set baseFolder to make new folder with properties {name:JobNumName}
repeat with i from 1 to count newsublist
try
set {tier2, t2Subs} to {item 1, item 2's items} of item i of newsublist
set tier2Folder to make new folder at baseFolder with properties {name:(tier2)}
repeat with tier3 in t2Subs
make new folder at tier2Folder with properties {name:(tier3)}
end repeat
on error
make new folder at baseFolder with properties {name:(item 1 of item i of newsublist)}
end try
end repeat
activate
open thepath
end tell

There are a few differences with Leopard that still get me from time to time. Tiger's AppleScript doesn't like path to desktop, so instead use the statement:
set ThePath to (get path to desktop folder)
The other thing I hadn't noticed before is if there is an error, the script just stops instead of throwing up a dialog. If you are doing something like using an illegal file name or trying to create a folder in a location that you don't have permissions, then unless the MakeFolderStructure statement is in a try statement it will fail silently. Adding an error display will at least tell you if there is an error, so a script that works in Tiger (as well as Leopard) is:
<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 a folder structure at the currently selected Finder item
tell application "Finder" to try -- get the current selection
set ThePath to the first item of (get selection)
if the last character of (ThePath as text) is not ":" then -- a file
set ThePath to the container of ThePath
end if
on error -- default to the desktop
set ThePath to (get path to desktop folder)
end try
set JobName to text returned of (display dialog "Please enter Job Name:" default answer "Job Name")
set textYear to text -2 through -1 of ((current date)'s year as text)
set JobNum to text returned of (display dialog "Please enter Job Number:" default answer {textYear & "xxx"})
set JobNumName to JobNum & "_" & JobName
try
MakeFolderStructure out of {JobNumName, {"Builds", {"versions"}, "Links", "Fonts", "Proofs"}} at ThePath
on error ErrorMessage number ErrorNumber -- oops
activate me
display alert "Error " & ErrorNumber message ErrorMessage
end try
to MakeFolderStructure out of SomeItem at SomeFolder
make the folder structure defined in SomeItem at SomeFolder
SomeList defines the structure:
nested list items create folders in the previous text item - {"A", {"B", {"C"}}} = /A/B/C
empty text items will create untitled folders
parameters - SomeItem [mixed]: the folder structure
SomeFolder [alias]: the destination folder
returns nothing
set ParentFolder to SomeFolder
if class of SomeItem is list then
repeat with AnItem in SomeItem
if class of AnItem is list then -- add subfolder(s)
MakeFolderStructure out of AnItem at SomeFolder
else -- add a new child folder at the current parent
tell application "Finder" to make new folder at ParentFolder with properties {name:AnItem}
set SomeFolder to the result as alias
end if
end repeat
else -- add a new (potential) parent folder
tell application "Finder" to make new folder at SomeFolder with properties {name:AnItem}
set ParentFolder to the result as alias
end if
end MakeFolderStructure</pre>

Similar Messages

  • Authorization for creating Jobs

    Hi everybody,
    which profile or role in su01 is necessary for creating jobs by a program? Until now i can only generate jobs with sap_all.
    regards,
    Sid

    You'll find them through SU03.
    Look at these Authorizations objects
    S_BTCH_ADM, S_BTCH_JOB and S_BTCH_NAM.

  • AppleScript for renaming new folders from filenames??

    I want to put a bunch of files in their own individual folders with the foldername matching the file inside without the file extension.
    So say I select 30 files > create folder for each file > move these files into their own folder > name the folder the filename w/o extension
    I want to be able to do this with a single file or a batch. I've been messing around in Automator but haven't achieved what I want to do fully. I'd greatly appreciate anyone's help with this Thanks!!

    You can use Automator to create a Service, and place a script in a Run AppleScript action, for example:
    Service receives selected files or folders in Finder
    Run AppleScript:
    on run {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
        tell application "Finder" to make new folder at theParent with properties {name:theChild}
        return the result as alias
      end try
    end makeNewFolder

  • No F4 value for system and client field for create job request

    Hi,
    While creating a job request in Solution manager system filed and client filed F4 is not working , it does not show any value.
    Do you have  any idea regarding this issue.
    Thansk & Regards,
    kaushal

    Hello  Kaushal,
    you habe to link user, key user i.e. a business partner (BP), and managed system and this work like this:
    a) User <-> BP: start transaction BP, assign role Employee to your business partner and enter the user name on tab Identification
    b) BP <-> managed system: start transaction BP, select role General and enter the External System Identifier (format: <managed system ID> <installation number> <client> <user in managed system>) on tab Identification
    Alternative: Use transaction BP_GEN to create valid business partners for managed systems
    See also the Solution Manager Implementation Guide (IMG):
    -> transaction SPRO
    .> SAP Solution Manager Implementation Guide
    -> SAP Solution Manager
    -> Cross-Scenario Settings
    then
    -> Business Partners
    and
    -> iBase
    (Note that IMG path (and labels) might vary in between support packages)
    Kind regards,
    Martin
    http://service.sap.com/jsm

  • Applescript to create alphabetical folders....

    I have searched everywhere and can't figure out how to do this. I want to create a list of folders with the letters of the alphabet as the name. Example: A, B, C, etc. - for filing purposes. Anybody have any suggestions?

    Here's a way to accomplish the same thing type of thing without using the Finder.
    <pre style="margin: 0px; padding: 5px; border: 2px dotted green; width: 600px;
    height: 100px; color: #ffffff; background-color: #000000; overflow: auto; font-family: Verdana, Monaco, monospace; font-weight: 900; font-size: 12px;"
    title="Copy this text and paste it into your Script Editor application.">set theFolder to POSIX path of (choose folder)
    repeat with x from 65 to 90
    do shell script "mkdir " & quoted form of (theFolder & (ASCII character x))
    end repeat</pre>
    Hope this helps...

  • Applescript for creating a network at start-up

    Everytime I start up my mac the network I created is gone and I have to create a new one.
    So I want to create an applescript that I can use as start-up item (application)
    I found an applescript on the net but that one isn't working on my mac. So I changed it a little.
    It works for "turn airport on" (instead of "Open Network Preferences...")
    But "Open Network Preferences..." is below a grey line.
    What am I doing wrong?
    property CreateMenuName : "Create Network…"
    property NetworkName : "Net"
    property NetworkPassword : "paswd"
    tell application "System Events"
              tell process "SystemUIServer"
      tell menu bar 1
      set menu_extras to value of attribute "AXDescription" of menu bar items
      repeat with the_menu from 1 to the count of menu_extras
                                            if item the_menu of menu_extras is "Airport Menu Extra" then exit repeat
      end repeat
      tell menu bar item the_menu
                                            perform action "AXPress"
                                            delay 0.2
                                            perform action "AXPress" of menu item "Open Network Preferences..." of menu 1
      end tell
      end tell
      repeat until exists window 1
                                  delay 0.5
      end repeat
      tell window 1
      click checkbox 1
      click pop up button 2
      click menu item 2 of menu 2 of pop up button 2
      click checkbox 1
      set value of text field 2 to NetworkPassword
      set value of text field 3 to NetworkPassword
      set value of text field 1 to NetworkName
      click button 1
      end tell
      end tell
    end tell

    Well in another discussion I got the answer of keeping your self created network when closing and starting up your mac. The created network will be remembered in System Preferences/Sharing/Internet Sharing/Airport options.
    But somehow it needs to be activated. And you can do that by un-clicking "Internet Sharing" and clicking it again and click "Start" So with thanks to BDAqua I came to the following Automator workflow to be saved as an application which you can put in System Preferences/Accounts/ login-items.
    on run {input, parameters}
    tell application "System Preferences"
    activate
    end tell
    tell application "System Events"
    tell process "System Preferences"
    click menu item "Sharing" of menu "View" of menu bar 1
    delay 2
    tell window "Sharing"
    click checkbox 1 of row 10 of table 1 of scroll area 1 of group 1
    delay 1
    if (exists sheet 1) then
    if (exists button "Turn AirPort On" of sheet 1) then
    click button "Turn AirPort On" of sheet 1
    delay 1
    end if
    click button "Start" of sheet 1
    end if
    end tell
    end tell
    end tell
    tell application "System Preferences"
    activate
    end tell
    tell application "System Events"
    tell process "System Preferences"
    click menu item "Sharing" of menu "View" of menu bar 1
    delay 2
    tell window "Sharing"
    click checkbox 1 of row 10 of table 1 of scroll area 1 of group 1
    delay 1
    if (exists sheet 1) then
    if (exists button "Turn AirPort On" of sheet 1) then
    click button "Turn AirPort On" of sheet 1
    delay 1
    end if
    click button "Start" of sheet 1
    end if
    end tell
         end tell
    end tell
    tell application "System Preferences"
    quit
    end tell
    return input
    end run

  • Applescript for deleting user folders

    Hi,
    So I am managing a group of about 80+ iMacs and an Xserve.  I would like to delete the contents of the users folder excluding the arduser (user i will be using to run script), shared folder and a desktop alias file.  I want to be able to connect to the server from computer im wiping click on the script and have it run without having to choose folders and click extra things, just double click and done.  Ideally I would like this script to do much more, such as delete all cs3, 4, 5 apps and a couple of app folders all in one swoop.  Would love some help, I am new to Applescripts and am unfamiliar witht the language.
    Thanks

    I'm not sure I understand this. Why would you log into the server to wipe the users on the local machine? Why not wipe them from the local machine directly?
    In any case, this is better accomplished with bash rather than AppleScript.
    Suppose you have a user account called 'John' on the local machine. You'd use
    sudo rm -rf /Users/John/*
    and that would wipe out everything in the users account, but leave the parent directory 'John' in place (and empty).
    The next time you log in to user 'John' on that machine, the OS will recreate default System folders (Desktop, Documents, Downloads, Library, Movies, Music & Pictures).

  • Creating .app folders in other operating systems?

    I'm working on a cross-platform game and am hoping to create an OS X port of it. I don't have access to a mac, and so am unable to use the xcode tool for creating .app folders. Are there any tools for creating .app folders on other operating systems? I'd prefer Linux, but can also use windows if required.
    Thanks
    Nathaniel

    Well, .app bundles are specific to Cocoa and Carbon applications... The closest way to make such applications is to use GNUStep (which is an open Cocoa) but it means to rebuild the whole app to make it work with Cocoa/GNUStep...
    However, application that are compatible with Mac OS X are not necessarily in .app bundles. Bundles are used for a specific purpose which gather files that the app should have really close, like its interface files (nib) that is used only with Cocoa or Carbon. If your app is neither Carbon nor Cocoa, there's no use in creating a .app bundle it doesn't even exist. And moreover, Xcode (or Project Builder on GNUStep) is the only app that creates .app bundles.

  • Job dependecny with Not running for other jobs condition

    Hi,
    I have a job chain which should run with the below conditions
    1) at 19:00 GMT.
    2) Also it has another dependency that it should check for job x and job y and both these job x and job y should not be running.
    I checked for creating job locks and locks can be used for two jobs and it compliments each other and cannot be used in this case.
    How do I set this dependency in this case.
    Thanks.

    Hello,
    Then I don't understand the scenario.
    So the 19:00 job can only start when job x and y are not running. But job x and y can start when the 19:00 job is running?
    In that case create a pre-running action on the 19:00 job that checks if job x or y are running and waits for them to finish.
    Regards Gerben

  • HT201320 Does my email service provider have to provide the ability for me to create an IMAP email account in order for me to create Sub-folders within Apple Mail?

    Hi, Apple Mail provides a function to create sub-folders within my mailbox so that I can group emails of similar subjects or from the same sender. My service provider only provides POP email protocol and the New Folder button does not appear in my Apple Mail account for that service provider. Icloud provides the opportunity for the iPad user to select between POP and IMAP. I can select IMAP and the New Folder button appears allowing me to create sub-folders within the icloud email account. Does this mean I cannot create sub-folders in my email account unless my service provider provides customers with the option of creating an IMAP email account?
    This appears to be a problem for quite a few Apple Mail users, but service providers appear reticent to provide a response other than 'use Microsoft Exchange / Hotmail, Google GMail, or some other third party email service provider'. This is why I have chosen icloud as my email service provider. It is Apple and therefore Apple supports it. I have been a Telstra customer for over 15 years and they informed me today, strongly, that they support their own products and services, not Apple products, even though Telstra sell them. When I asked the Telstra Customer Support Manager whether they support Telstra customers, I was informed 'no, because the Telstra customer is not a Telstra product or service'. I have since cancelled my Telstra email account and am in the process of cancelling all of my Telstra services.

    Apple Sceptic wrote:
    Does this mean I cannot create sub-folders in my email account unless my service provider provides customers with the option of creating an IMAP email account?
    Yes. That is what it means. You need an IMAP account in order to create sub folders on the iPad.

  • I bought a new iMac.  iWeb and all folders migrated over, no problem, but I cannot bring up my website - it only seems to allow for creating a new site.

    I bought a new iMac.  iWeb and all its folders migrated over, no problem, but I cannot bring up my website - it only seems to allow for creating a new site.

    You need the 'Domain' file in which iWeb keeps its data. This lives by default in (user)/Library/Application Support/iWeb. You need to locate it on the old machine and copy it to the same position in the new machine. Note that it is the Library folder in your Home folder, not the one at root level.
    This folder is hidden on Lion and above; to access it, in the Finder go to the ‘Go’ menu and hold down the Option (Alt) key; the Library folder will appear as a choice. In Mavericks you can make it permanently visible - open your Home Folder the from the Finder's View menu, choose show View Options and check Show User Library.

  • How to make a CD of MP3 songs to play on a Bluray player without ITunes creating separate folders for each album

    I'm trying to make a CD full of MP3 files that I can play on my Bluray player for a long party, but when I burned the disc using ITunes, it created separate folders for each source album, and it won't play.  You have to open each individual album to get the songs to play.
    Can you make a cd that has all of the songs in one folder?

    I'm trying to make a CD full of MP3 files that I can play on my Bluray player for a long party, but when I burned the disc using ITunes, it created separate folders for each source album, and it won't play.  You have to open each individual album to get the songs to play.
    Can you make a cd that has all of the songs in one folder?

  • Spool list is not getting created for background job

    I am creating background job using JOB_OPEN and then submitting my z-report using submit statement and then closing job using JOB_CLOSE. for this job is getting creating in sm37 and also gets finished but it does not create spool list showing output.
    Any idea how to do this?
    Thanks in advance.

    DATA: lv_jobname TYPE tbtcjob-jobname,
            lv_jobcount TYPE tbtcjob-jobcount,
            lv_variant TYPE variant,
            wa_var_desc TYPE varid,
            wa_var_text TYPE varit,
            it_var_text TYPE TABLE OF varit,
            it_var_contents TYPE TABLE OF rsparams.
      REFRESH: it_var_contents, it_var_text.
      CLEAR: wa_var_desc, wa_var_text.
      CALL FUNCTION 'RS_REFRESH_FROM_SELECTOPTIONS'
        EXPORTING
          curr_report     = sy-cprog
        TABLES
          selection_table = it_var_contents
        EXCEPTIONS
          not_found       = 1
          no_report       = 2
          OTHERS          = 3.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
      CONCATENATE sy-datum sy-timlo INTO lv_variant.
      wa_var_desc-mandt       = sy-mandt.
      wa_var_desc-report      = sy-cprog.
      wa_var_desc-variant     = lv_variant.
      wa_var_desc-transport   = 'F'.
      wa_var_desc-environmnt  = 'B'.
      wa_var_desc-version     = '1'.
      wa_var_desc-protected   = 'X'.
      wa_var_text-mandt = sy-mandt.
      wa_var_text-langu = sy-langu.
      wa_var_text-report = sy-cprog.
      wa_var_text-variant = lv_variant.
      lv_jobname = lv_variant.
      CONCATENATE 'Batch Job Variant -'(006)
                  sy-uname INTO wa_var_text-vtext.
      APPEND wa_var_text TO it_var_text.
    Create the varaint for the back ground job.
      CALL FUNCTION 'RS_CREATE_VARIANT'
        EXPORTING
          curr_report               = sy-cprog
          curr_variant              = lv_variant
          vari_desc                 = wa_var_desc
        TABLES
          vari_contents             = it_var_contents
          vari_text                 = it_var_text
        EXCEPTIONS
          illegal_report_or_variant = 1
          illegal_variantname       = 2
          not_authorized            = 3
          not_executed              = 4
          report_not_existent       = 5
          report_not_supplied       = 6
          variant_exists            = 7
          variant_locked            = 8
          OTHERS                    = 9.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
    Open the job.
      CALL FUNCTION 'JOB_OPEN'
        EXPORTING
          jobname          = lv_jobname
        IMPORTING
          jobcount         = lv_jobcount
        EXCEPTIONS
          cant_create_job  = 1
          invalid_job_data = 2
          jobname_missing  = 3
          OTHERS           = 4.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
               WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
    submitt the job in background mode.
      CALL FUNCTION 'JOB_SUBMIT'
        EXPORTING
          authcknam               = sy-uname
          jobcount                = lv_jobcount
          jobname                 = lv_jobname
          report                  = sy-repid
          variant                 = lv_variant
        EXCEPTIONS
          bad_priparams           = 1
          bad_xpgflags            = 2
          invalid_jobdata         = 3
          jobname_missing         = 4
          job_notex               = 5
          job_submit_failed       = 6
          lock_failed             = 7
          program_missing         = 8
          prog_abap_and_extpg_set = 9
          OTHERS                  = 10.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
               WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
    close the job.
      CALL FUNCTION 'JOB_CLOSE'
        EXPORTING
          jobcount             = lv_jobcount
          jobname              = lv_jobname
          strtimmed            = 'X'
        EXCEPTIONS
          cant_start_immediate = 1
          invalid_startdate    = 2
          jobname_missing      = 3
          job_close_failed     = 4
          job_nosteps          = 5
          job_notex            = 6
          lock_failed          = 7
          invalid_target       = 8
          OTHERS               = 9.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
               WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
    Hope this will be helpful..

  • Creat Job for LSMW (periodical data transfer)- idoc BLAORD

    Hi,
    We are trying to create job for LSMW (thru frame program for periodic data transfer) for idoc BLAORD (Purchasing contract)
    When I am running the job that I created, the job is cancelled and the error is:
    "Upload from front-end is not possible in batch mode.
    Message no. /SAPDMC/LSMW_OBJ_070 020"
    How can I correct that? so I will be able to run a job (the job mast run background?)
    Thanks,
    Tal Sasson

    Hello,
    I was also receiving the same message /SAPDMC/LSMW_OBJ_070 020 even though I specified in /SAPDMC/SAP_LSMW_INTERFACE the server path. The problem was that in LSMW->Specify Files you have to delete the definition of front-end files and define application server files.
    That Flag File (Path and Name) (field /SAPDMC/LSOINP-FILENAME in program /SAPDMC/SAP_LSMW_INTERFACE) is kind of useless since it is ignored anyway and files defined in LSMW object are imported and they have to be read anyway if you use more than one file.
    Regards,
    Peter

  • Create new folders for old messages on my computer

    How do I create new folders in my computer to archive old messages and save them to my computer.

    Do you mean in Mail or the Finder? In Mail simply click on the [+] button at the bottom left of the folders fist. Select New Folder. In the dialog select where you want the folder located and the name for it.
    In the Finder navigate to where you want to create the folder then press SHIFT-COMMAND-N to create a new "untitled" folder.

Maybe you are looking for