Trying to create a shell script to cut/paste files in finder. Help needed.

I'm trying to create an automator shell script to cut/paste. It'll function exactly like copy/paste. i.e. I'll just copy file/files with command+c like always, but then I'll create an automator which uses the "mv" terminal app to move the files which works exactly like cut paste.
I need some help since I don't know the syntax for creating shell scripts.
What I did so far is to do it in automator with Apple Script which goes like the following:
on run {input, parameters}
tell application "Finder"
set theWindow to window 1
set thePath to quoted form of (POSIX path of (target of theWindow as string))
end tell
tell application "Terminal"
do script with command "mv \"" & input & "\"" & thePath in window 1
end tell
return input
end run
This gets the copied file path from clipboard before, as input, and then recognizes the active finder window as thePath so then executes the mv command for the input file to the thePath window.
It doesn't work as expected since it connects both file/window paths into a single path instead of leaving a space between them so the mv command can't recognize two separate paths.
What's the correct syntax for that line
do script with command "mv \"" & input & "\"" & thePath in window 1
to leave a space between input and thePath under the mv command?
Also this requires the terminal app to be open in the background.
After I get this to work I want to do the exact same thing using shell script within automator, so I won't need Terminal to be open all the time.
And the next step will be to cut/paste multiple files/folders but that should be easy to do once I get the hang of it.

Try using:
on run {input, parameters}
tell application "Finder"
set theWindow to window 1
set thePath to quoted form of (POSIX path of (target of theWindow as string))
end tell
do shell script "mv \"" & input & "\" " & thePath
return input
end run
(45977)

Similar Messages

  • Need Help in creating Unix Shell Script for database

    Would be appreciable if some one can help in creating unix shell script for the Oracle DB 10,11g.
    Here is the condition which i want to implement.
    1. Create shell script to create the database with 10GB TB SPACE and 3 groups of redo log file(Each 300MB).
    2. Increase size of redolog file.
    3. Load sample schema.
    4. dump the schema.
    5. Create empty db (Script should check if db already exists and drop it in this case).
    6. Create backup using rman.
    7. restore backup which you have backed up.

    This isn't much of a "code-sharing" site but a "knowledge-sharing" site.  Code posted me may be from a questioner who has a problem / issue / error with his code.   But we don't generally see people writing entire scripts as responses to such questions as yours.  There may be other sites where you can get coding done "for free".
    What you could do is to write some of the code and test it and, if and when it fails / errors, post it for members to make suggestions.
    But the expectation here is for you to write your own code.
    Hemant K Chitale

  • How do i create a "shell script" as root? [SOLVED]

    Really a newbie question, i know, but any how.
    I just downloaded and installed a google-drive client and is about to set it all up. Following a guide from github.
    https://github.com/astrada/google-drive … tomounting
    "Create a shell script named gdfuse in /usr/bin (as root) with this content:"
    There were no explanation how to create a shell script. So i just want to know how du i do that?
    I assume it's really simple,  when logged in as su in a terminal, but shell script is new to me.
    I read a tutorial on creating scripts, (http://linuxcommand.org/wss0010.php) but  dont know how to create the actual file. e.g. if i open leafpad and try to save it in the /usr/bin i presume it's not as root. Or shall i open thunar as root and do it that way?
    Last edited by dockland (2015-06-19 21:39:44)

    There's seldom need to run graphical application as root. For editing as root, it's best to stick to a text-based editor.
    One of the first hits on a ddg search for 'how to create a shell script' was http://www.linfo.org/create_shell_1.html
    Last edited by karol (2015-06-19 21:57:23)

  • Want to create unix shell script for  Clone procedure in 11i and r12

    Want to create unix shell script for Clone procedure in 11i and r12 .Can anyone help me on this as I m new to oracle apps and scripting.
    Thanks in advance .

    user11958935 wrote:
    Thanks but I want it for application cloning ie adcfgclone and autoconfig etc .Please see old threads for similar topic/discussion.
    https://forums.oracle.com/forums/search.jspa?threadID=&q=Automate+AND+Rapid+AND+Clone&objID=c3&dateRange=all&userID=&numResults=15&rankBy=10001
    https://forums.oracle.com/forums/search.jspa?threadID=&q=Automate+AND+AutoConfig&objID=c3&dateRange=all&userID=&numResults=15&rankBy=10001
    Thanks,
    Hussein

  • Trying to create a Photomerge in Bridge, when the files open in Photoshop ( small jegs ) , I get a error message of " Unable to process latte files " / " null is not an object "

    Trying to create a Photomerge in Bridge, when the files open in Photoshop ( small jegs ) , I get a error message of " Unable to process latte files " / " null is not an object "
    Please help

    Wait a second, Photoshop can make lattes now?  Personally I prefer my coffee black, but man have I been under-utilizing this program.

  • I have been trying to create an apple ID for the past 2 days and cannot succeed : it states an unknown error has occurred and no ID is created. What to do?

    i have been trying to create an apple ID for the past 2 days and cannot succeed : it states an unknown error has occurred and no ID is created. What to do?

    The internet is the internet. if its not working then its something to do with your not allowing cookies from apple's site or they are having issues.

  • Passing shell script variable to sql file by reference (bind variable)

    Hi All,
    I need to import around 50 files every 15 minutes into my target table.
    I am using shell script and call procedure to do transform.
    I used crontab to do this automate task.
    Here is my shell script and sql file:
    shell script:
    #!/bin/sh
    export ORACLE_HOME=/u01/app/oracle/product/9.2.0.4.0
    export PATH=$ORACLE_HOME/bin
    find /path_rawfile/rawfile -iname raw\*.in > myfile.lst
    nfile=1
    while [ true ]
    do
    read iFile #read a line
    if [ $? -ne 0 ] #Break if EOF
    then
    break
    fi
    #$PATH/sqlplus -s /NOLOG @load_raw.sql $iFile
    #/bin/mv -f $iFile /path_rawfile/rawfile/done/
    done < myfile.lst
    sql file:
    connect test/test@evn1
    set serveroutput on
    variable filename varchar2(50)
    begin
    :filename := '&1';
    exec my_tranform(:filename);
    dbms_output.put_line(:filename);
    end;
    exit;
    Even I used bind variable pass to procedure my_transform...
    But when i query in sys.v_$sqlarea, the :filename:='&1' still hard parse to sqlarea.
    One filename one statement and keep increasing ..
    Could everyone help me to change it to bind varialbe(soft parse)?
    I would like to incresae my database performance.
    Thanks in advance.
    Cheer
    Message was edited by:
    lux

    It is the procedure.
    It's my fault.
    Here is my SQL file again:
    conn test/test@evn1
    variable filename varchar2(500);
    exec :filename:='&1';
    exec my_transform(:filename);
    exit;
    I call this sql file from shell script and call in loop due to i need to load all file one time.
    Once i use <<EOF it raise error that's why when I deleted it.
    Anyway, what I need to do here is to use bind variable (soft parse).
    Since I need to load around 50 files every 15 minutes.
    exec :filename:='&1'; this statmet have found hard parse in v_$sqlarea.
    I would like to change this to bind varialbe.
    Thanks again for your help.

  • Need  Shell Script  for picking the files

    Hi,
        I want to write a shell script for piking the files in a sequence order (according to filename with time stamp)  from the sorce FTP server ..
                     Requirement is  in the source directory I'm getting files (Jain_1.xml  , Jjain_2.xml, Jain_3.xml .. ect..)  at  present my file adapter is picking all the files at a time  but  i want to pick  one by one... that to first i want to Jain_1.xml  after finish the processing of the file then only my file adapter should  pick the next file ( Jain_2.xml )  .
                  so..  all the forum mates suggest me to write a shell script..  but where  i have to write the s hell script. and where i have to deploy this script.... my Xi is running on UNIX ... so please sugest me  the procedure ...
    Regards
    Jain

    Hi,
    Why dont you use the option EOIO in which files will be picked up in order and will be proccessed in sequence....one after another....
    Regards,
    Sreeni.

  • While Installing adobe reader and acrobat im getting error 1406 this error. I had already tried every possible step including special permission in registry file. Please help..

    While Installing adobe reader and acrobat im getting error 1406 this error. I had already tried every possible step including special permission in registry file. Please help..

    What is your operating system?  Is there anything else beside the number 1406?

  • [SOLVED]Cannot copy/cut/paste files in Konqueror

    Hi all, I am using KDE4.1.2 (official version). My konqueror cannot copy/cut/paste files in 'file manager' mode, the copy/cut/paste items in the right click menu are always faded out, and C-x/C-c/C-v hotkeys do not work either. However, it can read/write/rename/delete files normally. In fact, 'Move to' and 'Copy to' menu works too. Meanwhile, dolphin does not have this problem. I am a little confused.:mad:
    Last edited by hk2717 (2008-10-08 01:35:56)

    Hello,
    I'm using kdemod, konqueror 4.1.4 in i686, and the paste is always greyed out (same happens with the button in the taskbar). The "copy" action seems to be enabled through ctrl-c and the right-click, but there is no way to say, because no paste can be done. Deleting files works, so it does not seem to be related to permissions.
    Regarding the post
    http://bbs.archlinux.org/viewtopic.php?id=57749
    I installed konq-plugins, but it did not help. The paste is also greyed out in dolphin.
    I wonder if anyone is having this same issue? I thought this was solved in 4.1.3
    Thanks!
    Eduardo

  • HT1343 Why doesn't Command-X cut a file in finder?

    Why doesn't Command-X cut a file in finder?
    According to this article it must to! http://support.apple.com/kb/HT1343?viewlocale=en_US&locale=en_US
    What is  way to cut the a file WITH OUT using a mouse/trackpad - with keyboard only?

    http://lifehacker.com/5812127/how-to-copy-and-paste-in-the-mac-os-x-finder
    http://apple.stackexchange.com/questions/74507/cut-paste-files-or-folders-on-mac -os-x
    http://dailymactips.com/2012/09/18/how-to-cut-paste-files-and-folders-in-mac-os- x-mountain-lion/
    http://hints.macworld.com/article.php?story=201107211337186
    Command-C
    Command-Option-V

  • Trying to run Power shell Script on task schedule

    My case is i'm trying to run a power shell script through the task schedule.
    Note if i run the script locally it is working fine but from the task schedule it is not working.
    More information: 
    script function: Password Change Notification
    Task name : test3
    Time to do the task: 9:08 am every day
    the status : running 
    .ps1 file location: under C\windows\system32\
    some actions in the task history after the dated time to run:
    1 Task Scheduler launched "{3023b1eb-9b29-47b9-ace2-e6083e2f00cc}"  instance of task "\test3" due to a time trigger condition
    2 Task Engine "S-1-5-21-60622444-1628707926-2526327935-500: enviroment\Admin:S4U:LUA"  received a message from Task Scheduler service requesting to launch task "\test3" .
    3 Task Scheduler started "{3023b1eb-9b29-47b9-ace2-e6083e2f00cc}" instance of the "\test3" task for user "enviroment\admin
    4 Task Scheduler launched action ""C:\Windows\System32\Password Change Notification\Password Change Notification.ps1"" in instance "{3023b1eb-9b29-47b9-ace2-e6083e2f00cc}" of task "\test3
    5 Task Scheduler launch task "\test3" , instance "C:\Windows\System32\notepad.exe"  with process ID 5052

    Hi MeipoXu,
    First of all i would like to thank you for your answer, i followed the URL that you posted already in the previous comment and unfortunately it didn't work, and please find my ps1 file
    content as typed below and give me your feedback on that.
    #  # Version 1.1 May 2014
    # Robert Pearman (WSSMB MVP) # TitleRequired.com
    # Script to Automated Email Reminders when Users Passwords due to Expire.
    # # Requires: Windows PowerShell Module for Active Directory
    # # For assistance and ideas, visit the TechNet Gallery Q&A Page. http://gallery.technet.microsoft.com/Password-Expiry-Email-177c3e27/view/Discussions#content
    # Please Configure the following variables....
    $smtpServer="outlook. myDomain " $expireindays = 7
    $from = "الدعم الفني
    <ITHelpDesk@myDomain>"
    $logging = "Enabled" # Set to Disabled to Disable Logging
    $logFile = "PassExpireNotlog.csv" # ie. c:\mylog.csv
    $testing = "Enabled" ## "Enabled" # Set to Disabled to Email Users
    $testRecipient = "MyEmail@MyDomain"
    $encoding = [System.Text.Encoding]::Unicode $date = Get-Date -format ddMMyyyy
    # Check Logging Settings if (($logging) -eq "Enabled")
    {     # Test Log File Path
        $logfilePath = (Test-Path $logFile)     if (($logFilePath) -ne "True")
        {         # Create CSV File and Headers
            New-Item $logfile -ItemType File
            Add-Content $logfile "Date,Name,EmailAddress,DaystoExpire,ExpiresOn,MsgBody"
        } } # End Logging Check
    # Get Users From AD who are Enabled, Passwords Expire and are Not Currently Expired
    Import-Module ActiveDirectory $users = get-aduser -filter * -SearchScope Subtree -SearchBase "OU=UsersOU,DC=MyDomain,DC=MyrootDomain,DC=MYrootNS" -properties Name, PasswordNeverExpires, PasswordExpired, PasswordLastSet,
    EmailAddress |where {$_.Enabled -eq "True"} | where { $_.PasswordNeverExpires -eq $false } | where { $_.passwordexpired -eq $false }
    $maxPasswordAge = (Get-ADDefaultDomainPasswordPolicy).MaxPasswordAge
    # Process Each User for Password Expiry foreach ($user in $users)
    {     $Name = (Get-ADUser $user | foreach { $_.Name})
        $emailaddress = $user.emailaddress
        $passwordSetDate = (get-aduser $user -properties * | foreach { $_.PasswordLastSet })
        $PasswordPol = (Get-AduserResultantPasswordPolicy $user)
        # Check for Fine Grained Password
        if (($PasswordPol) -ne $null)     {
            $maxPasswordAge = ($PasswordPol).MaxPasswordAge
        $expireson = $passwordsetdate + $maxPasswordAge
        $today = (get-date)     $daystoexpire = (New-TimeSpan -Start $today -End $Expireson).Days
                 # Set Greeting based on Number of Days to Expiry.
        # Check Number of Days to Expiry
        $messageDays = $daystoexpire     if (($messageDays) -ge "2")
        {         $messageDays = "خلال
    " + "$daystoexpire" + " ايام"
        }     elseif (($messageDays) -eq "2")
        {         $messageDays = "خلال يومين
        }     else
        {         $messageDays = "اليوم."
        }     # Email Subject Set Here
        $subject="كلمة المرور الخاصة بك ستنتهي
    $messageDays"
           # Email Body Set Here, Note You can use HTML, including Images.
        $body =     "<P style='font-family: Arial; font-size: 16pt' />
        <center> الاستاذ/ $name
    </center> 
        <br>     <center>
    كلمة المرور الخاصة بك ستنتهي $messageDays </center>
        <br>     <center>
    نأمل تغييرها في أقرب فرصة حتي تتمكن من الدخول على النظام
    </center>
        <br>     <center>
    مع تحيات الادارة العامة لتقنية المعلومات
    </center> 
        <br>     </P>"
            # If Testing Is Enabled - Email Administrator
        if (($testing) -eq "Enabled")
        {         $emailaddress = $testRecipient
        } # End Testing     # If a user has no email address listed
        if (($emailaddress) -eq $null)
        {         $emailaddress = $testRecipient    
        }# End No Valid Email     # Send Email Message
        if (($daystoexpire -ge "0") -and ($daystoexpire -lt $expireindays))
        {          # If Logging is Enabled Log Details
            if (($logging) -eq "Enabled")
            {             Add-Content $logfile "$date,$Name,$emailaddress,$daystoExpire,$expireson,$body" 
            }         # Send Email Message
            Send-Mailmessage -smtpServer $smtpServer -from $from -to $emailaddress -subject $subject -body $body -bodyasHTML -priority High -Encoding $encoding
                    } # End Send Message
      } # End User Processing
    # End

  • Creating simple shell script packages to deploy with ARD and TaskServer

    I am looking for a simple step by step on how to create a package that can be deployed using ARD, to run a simple shell script like
    "softwareupdate -i -a"
    A brief search here returned nothing, but perhaps I was not using the correct terms.
    Ultimately, I want to use ARD to run software update on ~400 Macs.
    Thanks in advance for your help.
    Bill

    If I send it as a unix command, it will run only on machines that are currently awake and responding to ARD.
    If I can set it up as a package, then I can use Task Server to "deploy" the command to machines that are not currently online. When the machines next contact the Task Server, they will be told to run softwareupdate.

  • How to create power shell script to upload all termset csv files into the SharePoint2013 local taxonomy ?

    Hi Everyone,
    I want to create a powershell script file
    1) Check a directory and upload all termset csv files into the SharePoint local taxonomy.
    2) Input paramaters - directory that containss termset csv files, Local Termstore to import to,
    3) Prior to updating get a backup of the existing termstore (for rollback/recovery purposes)
    4) Parameters should be passed in via XML file.
    Please let me know how to do it.
    Regards,
    Srinivas

    Hi,
    Please check this link
    http://termsetimporter.codeplex.com/
    Please remember to click 'Mark as Answer' on the answer if it helps you

  • How to solve this problem in shell script: unexpected end of file

    Hello,
    I need to connect to each databases listed in /etc/oratab and check which database is shutdown(or mounted-only) and which database is opened to accept connection. However, following shell script gives me this error message:
    $>./check_is_db_runing.sh
    ./check_is_db_runing.sh: line 39: syntax error: unexpected end of file
    Could anyone please help me to solve this problem, why the code (line 29 to 32) does not work in the LOOP? It works without the LOOP.
    Thanks in advance!!!
    1 #!/bin/bash
    2
    3 LOGDIR=/data03/oracle/dbscripts
    4 ORATABFILE=/etc/oratab
    5
    6 cat $ORATABFILE | while read LINE
    7 do
    8 case $LINE in
    9 \#*) ;; #comment-line in oratab
    10 *)
    11 ORACLE_SID=`echo $LINE | awk -F: '{print $1}' -`
    12 if [ "$ORACLE_SID" = '*' ] ; then
    13 # NULL SID - ignore
    14 ORACLE_SID=""
    15 continue
    16 fi
    17
    18 # Proceed only if last field is 'Y'
    19 if [ "`echo $LINE | awk -F: '{print $NF}' -`" = "Y" ] ; then
    20 if [ `echo $ORACLE_SID | cut -b 1` != '+' ]; then
    21
    22 ORACLE_HOME=`echo $LINE | awk -F: '{print $2}' -`
    23 PATH=$ORACLE_HOME/bin:/bin:/usr/bin:/etc
    24 export ORACLE_SID ORACLE_HOME PATH
    25 LOGFILE=$LOGDIR/check_$ORACLE_SID.log
    26 touch $LOGFILE
    27 #echo $LOGFILE
    28
    29 $ORACLE_HOME/bin/sqlplus -s "/ as sysdba" << EOF > $LOGFILE
    30 select * from global_name;
    31 exit
    32 EOF
    33
    34 fi
    35 fi
    36 ;;
    37 esac
    38 done

    This code works ie. generates logs with sql result - slightly modified to be runable:
    #!/bin/bash
    LOGDIR=/tmp
    ORATABFILE=/etc/oratab
    cat $ORATABFILE | while read LINE
    do
    case $LINE in
    \#*) ;; #comment-line in oratab
    ORACLE_SID=`echo $LINE | awk -F: '{print $1}' -`
    if \[ -z $ORACLE_SID \] ; then
    # NULL SID - ignore
    ORACLE_SID=""
    continue
    # Proceed only if last field is 'Y'
    else
    ORACLE_HOME=`echo $LINE | awk -F: '{print $2}' -`
    PATH=$ORACLE_HOME/bin:/bin:/usr/bin:/etc
    export ORACLE_SID ORACLE_HOME PATH
    LOGFILE=$LOGDIR/check_$ORACLE_SID.log
    touch $LOGFILE
    #echo $LOGFILE
    $ORACLE_HOME/bin/sqlplus -s "/ as sysdba" << EOF > $LOGFILE
    select * from global_name;
    exit
    EOF
    fi
    esac
    done

Maybe you are looking for

  • Payroll Query

    Hi Members, My Query is on payroll.  I have created payroll area and tried to create a control record with rectroactive accounting date as jan 2011 and Payroll period date as Aug 2011.  When Iam trying to save the record it is showing error as Payrol

  • Help with first Adobe Script for AE?

    Hey, I'm trying to create a script that will allow me to set a certain number of layer markers at an even interval to mark out a song. Could someone help me troubleshoot this script? I've been working on it for ages now, and I'm about to snap. I've b

  • Asset Explorer -- Acquisition Value Year-End

    Dear all, I'm looking on how to fetch a certain value... If you access transaction AS03 You'll see th master data for a certain asset. Now... if you click on the "Asset value"-button, you'll be redirected to transaction AW01N, "Asset Explorer". In th

  • Macbook Air Lion OX S 10.7.5 Need to reset second Admin Password

    I have three user accounts on my Macbook Air 11-inch (late 2011 model). Two are designated "Admin" in the "Users and Groups" I changed one user account password, thought I saved the password hint via email to myself and now find I cannot log in eithe

  • Photoshop CS6 not installed in Mac

    I was trying to install Photoshop CS6 in my MacBook Air, but an error message says that I cannot install it in a volume that makes difference between upper and lower case letters. I have only one HDD volume. How can I solve this?