Writing a shell script to move files

Hello,
I'm trying to write a shell script that will move files from one directory to another at a time specified by me. I've got a similar script attached to an Automator action, which is triggered nightly by iCal.
Of course, this one simply deletes files that are older than a day in a couple of locations. I'd like to have another that MOVES files and folders from one location to another. So far, I've come up with this:
find /Volumes/Location/01/* -type d -or -type f -mtime +7 -exec mv -f /Volumes/Location/01/* /Volumes/Location/02/ ;
Which just about works, but it actually seems to be moving all the files that are LESS than a week old. Any and all suggestions are appreciated, as I'm a total n00b here.

find /Volumes/Location/01/*
-type d -or -type f -mtime +7
-exec mv -f /Volumes/Location/01/* /Volumes/Location/02/ ;
Which just about works, but it actually seems to be moving all the files
that are LESS than a week old. Any and all suggestions are appreciated,
as I'm a total n00b here.
your -exec is not selecting the files or directories found by the 'find' command.
It is moving everything in /Volumes/Location/01/*
Looking at "man find", I think you want your -exec to be
-exec /Volumes/Location/01/{} /Volumes/Location/02/ ;
As red_menace has pointed out, you have to change your -type options
so that you select directories or files.
You may also want to include -prune so that you do not decend
into subdirectories.
While the following is untested, I might write the command like this:
find /Volumes/Location/01/*
-prune -mtime +7
( -type d -or -type f )
-exec mv -f /Volumes/Location/01/{} /Volumes/Location/02/ ;

Similar Messages

  • I need a shell script to move latest archivelogs from one server to another server..

    Hi,
         I need a shell script to move latest archivelogs from one server to another server..
    Thanks&Regards,
    Vel

    ea816fb9-f9ea-45ac-906f-36a8315970d0 wrote:
    Thanks it's really helpfull..
    Now i have pasted a shell script which generates archivelog and shows latest archivelog time..
    just check let me know the answer, that how i need to execute it..
    # Force a logswitch to get the last archivelog to the standby host
    ORACLE_SID=ORCL
    ORAENV_ASK=NO
    . oraenv >/dev/null 2>&1
    SwitchLogfile()
      # Do logswitch 
      RESULT=`echo "Alter system switch logfile;" | sqlplus -S / as sysdba | grep 'System altered'`
      if [ "$RESULT" = "System altered." ]
      then
      export RETURN=1
      else
      export RETURN=0
      fi
      # Do we need to do something with this return value?
      export RETURN
    GetArchiveTime()
      CURYEAR=`date +%Y`
      echo "set heading off;" > temp.sql
      echo "set termout off;" >> temp.sql
      echo "select to_char(first_time,'YYYY-MM-DD HH24:MI:SS') from v\$archived_log where sequence#=(select sequence# - 1 from v\$log where status='CURRENT');" >> temp.sql
      sqlplus -S / as sysdba <
    spool tempres.txt
    @temp.sql
    quit
    EOF
    cat tempres.txt | grep ${CURYEAR} | grep -v grep | awk '{print $1" "$2}'
    #rm -f temp.sql  tempres.sql
    SwitchLogfile
    GetArchiveTime
    You seem to have ignored Dude's VERY good advice and continue to press down this ill-advised path.  If you continue this approach, you WILL have problems at the very time you do not need any additional problems.  Trying to recover your production database at 2:00 in the morning is not the time to be getting errors from rman because it can't find what it needs - because you decided to move them around yourself.
    Please reconsider.

  • Unix shell script to batch file for windows

    Hello all,
    Iam writing a program in java in unix environment and iam executing using shell scripts in unix this program is for client-server environment
    which look like this:
    For server:
    #! /bin/ksh
    export CLASSPATH=/user/vpp/jal/classes:$CLASSPATH
    #set var for filename config file
    export JAL_CONF_FILE=/user/vpp/jal/conf/JALapp.conf
    java -DJAL_CONF_FILE=$JAL_CONF_FILE jalsvr/JALTCPServer 7776for client side it is
    #! /bin/ksh
    export CLASSPATH=/user/vpp/jal/classes:$CLASSPATH
    echo $CLASSPATH
    java jalcl/JALTCPClient msoc05:7776my question is know i want to execute them in windows by creating batch files runsvr.bat, runcl.batbut how
    i gave PATH by giving JRE path but what is the replacement of export because iam having all class files
    in /jalcl for clients and /jalsvr for server but want to create this batch file in separate /bin folder how to do.please help me

    Thank you for reply ,
    And sorry by mistake question repeated twice,
    but when iam executing those batch files it is throwing some exceptions,
    in that file you did not mention to set the JRE path whether it is not necessary and also there msoc05 is the machine name of unix system that need to kept or need to be changed with window IP address .please reply.
    thanks in advance.

  • Needing script to move files with name that starts with

    Here is part of the script that takes a excel file for the list to duplicate files from one folder the another. I would like it to use file name starts with instead exact file name. If I can get this to work I will not have to have a try for .jpg and a seperate try for .eps
                tell application "Finder"
                    try
                        duplicate (sourceFolder & theItem & ".jpg" as string) to destFolder with replacing
                    on error
                        do shell script "echo " & theItem & ">> $HOME/Desktop/NotFound.txt"
                    end try
                    try
                        duplicate (sourceFolder & theItem & ".eps" as string) to destFolder with replacing
                    on error
                        do shell script "echo " & theItem & ">> $HOME/Desktop/NotFound.txt"
                    end try
                end tell
    Thanks

    Ok here is the script that I've been using for a couple of years now with no problems, until I upgraded. Don't know what happened, because I cant even use it on a older system that we have. The error I get is when it tries to get the value of selection from Excel. It times out with no values. Thanks for any help!
    set sourceFolder to choose folder with prompt "Select the folder that contains images to move."
    set destFolder to choose folder with prompt "Select the destination folder"
    if sourceFolder is not destFolder then my moveImageFiles(sourceFolder as string, destFolder)
    on moveImageFiles(sFolder, dFolder)
        script o
            property valuesList : {}
        end script
       tell application "Microsoft Excel" to set o's valuesList to value of the selection
        if class of o's valuesList is not list then return -- not multiple selection
        set tc to (count o's valuesList)
        set dFolder to quoted form of POSIX path of dFolder
        set errorFile to quoted form of POSIX path of (sFolder & "filesNotFound or NotMoved.txt")
        do shell script "/bin/rm " & errorFile & " > /dev/null 2>&1 &" -- remove the error file (if it exists)
        repeat with i from 1 to tc
            repeat with thisValue in (get item i of o's valuesList)
                if contents of thisValue is not "" then -- not a blank cell
                    set tFile to quoted form of POSIX path of (sFolder & thisValue)
                    try
                        do shell script "shopt -s nocaseglob; /bin/mv -f " & tFile & "* " & dFolder
                    end try
                end if
            end repeat
        end repeat   
        do shell script "/usr/bin/open -b com.apple.textedit " & errorFile & " > /dev/null 2>&1 &"
    end moveImageFiles

  • Script to move files and compress

    Hi Guys,
    I am in need of a script that moves log files that are older than 14 days to a compressed folder. I would like to run this as a scheduled task that would run at the end of each week, and for the logs to go into the same compressed folder each week. Is this possible? And if so could anybody please help me? I have spent hours on this and I am really struggling as I dont have much knowlegde of scripting at all.
    Many thanks,
    Jack  

    Ah my Friend we're in Powershell land for that, and very easy it is.
    The compressing part is easy and does not require Powershell as long as the destination File system is NTFS
    Make a folder called Archive (or whatever name suits you) and in Windows Explorer, go into the Properties of that folder, Choose the "Advanced Button" and select "Compress Contents to Save Disk Space" and hit apply.
    Now you should see that folder change color.  Anything going into there is a compressed file.  The great part is you can view it like normal, it just uses far less disk space.   A Zip file might take even less but this is very easy to work with.
    As far as accessing the log files older than 14 days, presuming the Folder is called C:\Logfiles and the filenames end with the extension .LOG
    ---------- Archive old Logfiles - Powershell Script -------------------
    $TODAY=GET-DATE
    GET-CHILDITEM C:\LOGFILES\*.LOG | Where { $_.LastWriteTime.AddDays(14) -lt $TODAY } | MOVE-ITEM C:\LOGFILES\Archive
    ---------- Archive old Logfiles - Powershell Script -------------------
    All this does is look at the directory of files with the extension .LOG and check the last time the file was modified.  Anything older than 14 days is Moved to the Archive folder.   If the "Compression" attribute is enabled, there's your archive process :)
    And of course if you don't have Powershell on the machine in question, it's a quick update from Windows to bring it in :)
    Download Windows Management Framework - http://support.microsoft.com/default.aspx/kb/968929
    Cheers
    Sean
    The Energized Tech
    Powershell. It's so Easy and it's FREE!
    Dive in and use it now, It'll take no time. :)
    http://www.energizedtech.com
    http://www.itprotoronto.ca

  • Need a script to move files to folders

    Hi guys.  I have found a lot of similar threads but not something exactly like what I need.
    I have a ton of files that need to be sorted into folders of the same name.  I found scripts to help me with that however, I have some variations on the files with an extension to the file name that also need to be moved into the same folders.
    For instance, I have a folder named....
    spiegal_case_25_video_3
    and I have the following files that all need to be moved into that folder....
    spiegal_case_25_video_3.mp4
    spiegal_case_25_video_3.webmsd.webm
    spiegal_case_25_video_3_h.flv
    spiegal_case_25_video_3_m.flv
    spiegal_case_25_video_3_l.flv
    I have found scripts to get me part of the way there but I can't get the FLVs into the folders because of the _h _m and _l extensions on the file names.  Is there a way to move these files into their appropriate folders (maybe by ignoring the last 2 characters in the file name?)
    I have also found a script that will read everything up to the underscore, but that won't help since the file names have multiple underscores.  So I really need a script that can do the sorting while ignoring the last 2 characters in the file name.
    Can anyone help me out?  I'm not very script savvy.
    Thanks!

    I've tested the following script (under OS X 10.8.5) with 4 subfolders and 20 files, all located in a folder called "Master folder" located in a USB flash drive named "EXT_DRIVE". It seems to work flawlessly. In its present state, the script will replace any file already located in any of the subfolders.
    set theMasterFolder to POSIX file "/Volumes/EXT_DRIVE/Master folder"
    tell application "Finder"
        activate
        set theFolders to (folders of folder theMasterFolder) as alias list
        repeat with thisFolder in theFolders
            set thisName to name of thisFolder
            move (files of folder theMasterFolder whose name begins with thisName) to thisFolder with replacing
        end repeat
    end tell

  • Unix Shell Script to check file Format

    Hello
    I am New to shell scripting.Please help me to write a script for the below condition.Any help is highly appreciated.
    I will get a text file every month like the one below
    Sample file
    Payslip.txt
    ========
    EMPID EMAIL PCTAG#
    4946:[email protected]:151207
    4978:[email protected]:154434
    5091:[email protected]:160784
    5208:[email protected]:153601
    5211:[email protected]:158963
    5218:[email protected]:156967
    5247:[email protected]:153760
    5250:[email protected]:160078
    5276:[email protected]:154693
    I should check for the below conditions in the above file
    Conditions:
    =======
    1.File should be seperated by colon(;)
    2.EMPID should not be null
    3.Email address and pc tag# should be null if it is missing
    4.No empty record should be there
    All the above four conditions should be checked
    If any one of four conditions are not met then the file is invalid and it should exit with status saying that file is invalid.
    If all the four conditions are met it should say that the file is valid
    Any help is highly appreciated.It is urgent.
    Thanks in advance
    Manoj

    Try this :
    error()
    {       echo -n "Line "$NR "  "$LINE "  "       >>$STATUS
            echo $1                                 >>$STATUS
    NR=0
    STATUS=/tmp/status.txt
    rm -f $STATUS
    cat Payslip.txt | while read LINE
    do
            NR=`expr $NR + 1`
            ### Check colons ###########
            if [ ! "`echo $LINE | grep :`" ]; then
                    error "No colon"
                    continue
            fi
            EMPID=`echo $LINE | awk -F: '{print $1}'`
            EMAIL=`echo $LINE | awk -F: '{print $2}'`
            PCTAG=`echo $LINE | awk -F: '{print $3}'`
            ### Check null line ###########
            if [ ! "$EMPID" -a ! "$EMAIL" -a ! "$PCTAG" ]; then
                    error "Null line"
                    continue
            fi
            ### Check null EMPID ###########
            if [ ! "$EMPID" ]; then
                    error "No Empid"
                    continue
            fi
    done
    echo
    if [ -f $STATUS ]; then
            cat $STATUS
            echo
            echo "File is Invalid"
    else
            echo "File is Valid"
    fi
    echo

  • Automator: shell script to change file permissions

    Hey guys,
    Just created a workflow to copy some files from one location to another.
    Second thing I want to do is run a shell-script to set some file permissions recursively, some for the folders, the other for the files.
    I figured I could do the following:
    cd /IntoAFolder
    find . -type d -exec chmod 770 {} \;
    Unfortunately, this seems to be needed to be done as a sudo'er and thus requires the user's password.
    So the question is, how do I get that password and hand it to the shell script or is there another way of doing this?

    What I want to do is recursively chmod the subfolders and files of a "root"-folder.
    The way I know to do so is:
    cd /root-folder
    find . -type d -exec chmod 755 {} \;
    That will chmod all subfolders from the root-folder to 755.
    Next i want
    find . -type f -exec chmod 644 {} \;
    That will chmod all subfiles fromn the root-folder to 644
    Unfortunately, find gives me a permission denied when I run this command from the command-line. When I just manualy chmod everything that works fine but is a bit to much work when it comes down to a tree of 5 subfolders and 120 files.
    Waht basically hapens:
    The user selects a bunch of folders.
    Then they are copied to /Applications/RCT3.localised/Data/Styles/Themed
    and then I need to chmod them just to be sure, as sometimes stuff break along the way if you don't

  • Shell Scripting to replace file type

    Hey all,
    I'm having some trouble with a shell script. I'm trying to run a script that will look through all the folders in a given directory for a certain type of file (.data) and then will run a getfileinfo -t on the .data file and, if the type is "" (empty), replace it with a given string.
    So far I can get the command to look through directories and I can get it to echo the getfileinfo -t, but I can't put the result of the command into a variable so I can check to see if it meets the "" condition. Any help would be greatly appreciated.
    Also, I am doing this in CSH, but I am no opposed to doing it another way, just so long as it works.

    Hi JohnSka7,
       I really like Niel's solution but it can be done in a script without AppleScript if you have Apple's Developer Tools installed. I don't do csh so I'll give it to you in bash and leave it as an exercise to translate:
    #!/bin/bash
    oldIFS=$IFS
    IFS=$'\n'
    for FILE in $( find "$1" -type f -name "*.data" ); do
       IFS=$oldIFS
       if [ \"\" = $( /Developer/Tools/GetFileInfo -t "$FILE" ) ]; then
          /Developer/Tools/SetFile -t "XXXX" "$FILE"
       fi
    done
    This temporarily sets the Input Field Separator, IFS, to a newline so that the snippet can handle filenames containing spaces. It assumes that the first argument to the script is the directory to be searched. Of course you should change "XXXX" to the type code you want and you can arrange for that to be specified in another argument. If you copy-and-paste this into a script, be sure to replace the non-breaking spaces I've used for indention with real spaces.
    Gary
    ~~~~
       Maslow's Maxim:
          If the only tool you have is a hammer, you treat
          everything like a nail.

  • Need Help Writing a Shell Script

    Basically I'm writing a script that opens TextEdit so I can open it from the Terminal. I also want it to run in the background so I can continue using the Terminal without having to quit TextEdit first. So far I've figured out two ways of doing this, and neither one does exactly what I want it to do. Here's the first one I tried:
    /Applications/TextEdit.app/Contents/MacOS/TextEdit $@ &
    The problem with this is that if TextEdit is already running, it opens a new instance of it to open the files, and it doesn't bring the app into focus when I run it. So I decided to try this:
    open -a "TextEdit" $@ &
    This way all files open in the same instance of TextEdit and it brings the app to the front, but it won't let me save anything I don't have write privileges for, even if I run it with sudo. I Googled it and apparently what happens is it runs "open" as root but runs the actual application that I'm opening as the current user.
    So basically what I need to know is if there's a way of doing this that will congregate all files into the same instance of TextEdit and bring the app to the front when I launch it, but still let me run it as root with sudo. If not, is there at least a way to check if TextEdit is running and throw an error if it is?

    #!/usr/bin/env bash
    if ps ax | grep '[T]extEdit'; then
    echo "TextEdit is already running!"
    else
    /Applications/TextEdit.app/Contents/MacOS/TextEdit &
    fi
    open -a TextEdit "$@"
    osascript -e 'tell application "TextEdit" to activate'
    Example:
    your.script "text file.txt"
    NOTE 1: When posting code to this forum, enclose your code in
    ...your code goes here...
    This will make sure that all your indentation and other meta-characters that might get interpreted by the forum code will be left alone.
    NOTE 2: The $@ will ONLY preserve quoted strings as a single argument if it is specified as "$@". That is to say it MUST be inside a pair fo double-quotes. Otherwise it is the same as $* The missing ".." are what messed up your ability to treat a file with space as a single argument. ALSO NOTE, I specified the file on the command line inside quotes (could be single or double), or you could use  if you desire.
    NOTE 2 and a half:
    If you DO NOT want to put quotes around the space filled filename when invoking your script, you could change your "$@" to "$*"
    open -a TextEdit "$*"
    The difference is that using "$@" will allow specifying several filenames on the command line and TextEdit will open all of them at once. The use of "$*" means you can only open 1 file per use of your script. Not a big deal, but I figured you should know the options available to you.
    NOTE 3: I've simplified your script.
    I do not know why you decided that if you are root you wanted to use sudo, since sudo gives normal users root privileges, and root already has root privileges.
    Actually based on earlier exchanges, I would have thought that you wanted to start TextEdit using sudo, unless it was already running:
    sudo /Applications/TextEdit.app/Contents/MacOS/TextEdit &
    so that you had root privileges allowing you to write files in places you were normally not allowed. Then again, maybe I was reading the earlier posting wrong (won't be the first time ).
    NOTE 4: The use of
    if [ "$textedit" > /dev/null ]; then
    is just plain wierd This translates to the command:
    test "$textedit" >/dev/null
    which redirects standard output into /dev/null, so the actually command looks like
    test "$textedit"
    which will essentially return TRUE if $textedit has a string in it, and FALSE if $textedit is empty.
    I decided to just use the completion status of the grep command as a way to decide if TextEdit was running on not.
    NOTE 5: I simplified the ps|grep|grep command with a trick I learned several years ago. The '[T]extEdit' regular expression exactly matchs TextEdit, except that it DOES NOT match a ps line that has '[T]extEdit'. So I can get rid of one grep command because it will never match the grep command in the ps output.
    NOTE 6: I moved the open and osascript commands outside the if structure, as I assumed you wanted osascript to bring TextEdit to the foreground regardless of whether it was already running or not, and the open command was identical for both halfs of the if structure. If this is a bad assumption, feel free do put it back inside the if structure.
    Message was edited by: BobHarris

  • Shell Script to compare files

    Hi All,
    Below is the sample script used to compare two files, this can be enhanced further.
    DATE=`date +%Y%m%d`
    TIME=`date +%H%M%S`
    count = 0
    echo "Provide the TOP (e.g. XXFIN)" #| ${TEE}
    read TOP
    echo "Provide the inputs from these: FORMS or REPORTS or JAVA or XML or ADMIN_SQL or TEMPLATES"
    read TYPE
    FILE=${TOP}_${TYPE}_Compare_File_Results_${DATE}${TIME}.log
    TEE="tee -a ${FILE}"
    echo "##########################################################################################################################" | ${TEE}
    echo "File Comparison Type if Binary provide 'B' or 'O':" | ${TEE}
    read file_type
    echo file_type
    echo "Provide Production file path:" | ${TEE}
    read prod_path
    echo "Provide Fix file path:" | ${TEE}
    read fix_path
    echo "You have provided Production file path as :$prod_path" | ${TEE}
    echo "You have provided Fix file path as :$fix_path" | ${TEE}
    echo "Compare Results will be shown in file:" | ${TEE}
    echo "##########################################################################################################################" | ${TEE}
    for release in `ls -R $prod_path`; do #`ls /app/ebs/atgsidev01/gsidev01cust/xxcomn/java/Test/1/`; do
    if cmp -s "$prod_path/$release" "$fix_path/$release"
    then
    echo "TEST............="cmp -s "$prod_path/$release" "$fix_path/$fix" | ${TEE}
    fi
         if [ -f $fix_path/$release  ]
         then
              echo #"File Exists...." >> Compare_File_Results.txt
         if [ 'B' -eq "$file_type" ];
         then
         if diff -q "$prod_path/$release" "$fix_path/$release" ;
         then
              echo #"The files match"$release
         else
              echo "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" | ${TEE}
    echo "File Name:"$release | ${TEE}
              echo "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" | ${TEE}
         count=`expr $count + 1`
              echo "The files are different: "$release | ${TEE}
              diff -w "$prod_path/$release" "$fix_path/$release" | ${TEE};
         fi # End of if diff -q
         else
         if cmp -s "$prod_path/$release" "$fix_path/$release"
         then
              echo #"The files match"$release
         else
         echo "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" | ${TEE}
    echo "File Name:"$release | ${TEE}
              echo "==========================================================================================================================" | ${TEE}
         count=`expr $count + 1`
              echo "The files are different: "$release | ${TEE}
              diff -w "$prod_path/$release" "$fix_path/$release" | ${TEE};
              echo "==========================================================================================================================" | ${TEE}
              echo "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" | ${TEE}
         fi #End of if cmp -s
         fi #if [ 'B' -eq      
         fi # if [ -f
    done
    echo "##########################################################################################################################" | ${TEE}
    echo "Count of files=$count" | ${TEE}
    echo "##########################################################################################################################" | ${TEE}

    Thanks Suraj!
    ;) AppsMasti ;)
    Sharing is Caring

  • Shell script, automator and file permissions

    We have an environment where, that when a user creates a folder on a network vol, it is owned by them and no one else has access to it. They then place a folder structure from there local HD into that folder they just created on the server. You would think a simple get info window with the user changing the permissions to include all would actually change all the file permissions in the enclosed folder, but it doesn't. I have a simple script written in automator using /bin/bash that is supposed to change the permissions in every folder and file to rw for all (user, group and everyone). It doesn't seem to be working correctly all the time for a few users.
    for f in "$@"
    do
    chmod -R 777 "$f"
    done
    I have tried this as well
    for f in "$@"
    do
    chmod -R a+rw "$f"
    done
    But that should be pretty much the same thing.
    Something i have noticed is the users with the most problem are running 10.4.11, while the script was written in 10.5. Also the users that are having the problem dont seem to have the same get info window as the rest of the 10.4.11 users, it very closely resembles 10.5, with some minor differences. It seems they are missing the groups or something. This might be more or less than an issue than I realize.
    http://picasaweb.google.com/tiemmothi/UserPermissions?feat=directlink
    the 10.4 window in question is "the offender" and
    "Mine" is 10.5

    *Access Control List* entries are in addition to the regular POSIX permissions. They are not required, but add finer levels of access control. Setting the regular permissions to read/write for everyone should work unless there are ACL entries which allow additional access - you can see ACL entries and extended attributes with/bin/ls -le@d /path/to/some/folder
    An inherited ACL entry to allow everyone read/write access would look something likechmod -R +a "everyone allow list,addfile,search,delete,add_subdirectory,delete_child,readattr,writeattr,chown,file_inherit,directoryinherit" /path/to/some/folderA users */Public/Drop Box* folder has similar entries.

  • Shell script to determine file width, height, resolution cs5 js

    I’ve been using a Script by Michael L Hale (that utilizes »xmp.getProperty« and Bridge’s »core.quickMetadata«) to determine files’s dimension and resolution without having to open or place them.
    Unfortunately it fails with some files (non-Photoshop generated bitmaps, it seems).
    (Pdfs I treat differently altogether to avoid the trouble of determining pdf-page counts and potential problems with pdfs containing differently sized pages.)
    Do any of you know if and how one can access files’ width, height, resolution with »app.system« in CS5?
    I may have come across it before, but can’t locate such a thread currently.
    Thanks for any input.

    These are 2 options that you could use if you wanted to dump all the info to text file then parse in JS. You could see if either of these contain the data that you are after?
    #target bridge
    var foo = File('~/Desktop/SomeFile.tif');
    getAllXMLSIPS(foo);
    //getMetaDataMDLS(foo)
    function getAllXMLSIPS(f) {
         if (f instanceof File && f.exists) {
              var shellString = "sips --getProperty allxml ";
              shellString += f.fsName;
              shellString += ' > ~/Documents/StdOut.txt';
              app.system(shellString);
    function getMetaDataMDLS(f) {
         if (f instanceof File && f.exists) {
              var shellString = "/usr/bin/mdls ";
              shellString += f.fsName;
              shellString += ' > ~/Documents/StdOut.txt';
              app.system(shellString);

  • 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.

  • Executing a shell script from a Trigger

    All,
    I have to write a script to do the following requirement.
    There is a file called BUSINESS_DATE.TXT.
    This file get updated once the oracle partition created. In Oracle, Partition will be created every day. There is a seperate script scheduled to take care ORACLE partition creation.
    The above file will have only one row. i.e
    03092012
    If Oracle partition creation job failed, the above file won't be updated.
    My requirement is,
    I have to check whether the BUSINESS_DATE file is updated today or not. If yes, I will have to move the files from common area to input file directory to process those files.
    All file name will amend with current date.
    i.e
    LIDDIFD03092012.TXT
    The key part is to check the BUSINESS_DATE.TXT file is updated properly or not.
    We don't know what time the file will get updated. So we are planning to schedule the new script to run for every 15 mins to check whether the file is updated or not
    But...I just thougt instead of writing a shell script to do the above one, Why shouldn't I capture the date in a table (New table needs to be created) and use ORACLE TRIGGER to run the shell script to move the files from common area to input file directory to process those files?
    My Proposal in ORACLE :
    Create table business_date
    rep_date varchar(15),
    curr_timestamp timestamp
    Once the oracle partition created , one row will be inserted into the above table. This adjustment needs to be implemented partition script.
    Once this table get record, TRIGGER should call SHELL SCRIPT to move the files from common area to input area.
    If I implement ORACLE TRIGGER, The script which will check whether the file got updated or not for 15 mins is not required. Right? Inputs from experts are welcome!

    >
    But...I just thougt instead of writing a shell script to do the above one, Why shouldn't I capture the date in a table (New table needs to be created) and use ORACLE TRIGGER to run the shell script to move the files from common area to input file directory to process those files?
    >
    Triggers should not be used to do transactional work. There is no COMMIT in a trigger. What happens if the trigger runs the shell script and then a ROLLBACK occurs? You will have run the shell script when it shouldn't run.
    Create a stored procedure to run the shell script. Call the stored procedure when the partition is created.
    If you were using 11g and interval paritioning you wouldn't need to create the partitions manually. Oracle could create the partitions automatically.

Maybe you are looking for

  • Need to know the difference between SRM workflow and Normal Ecc 6.0 Worflow

    Hi All, I have worked on Ecc 6.0 worflow, just wanted to know how is SRM workflow going to be different than the ECC6.0 worflows. Incase if someone can suggest some links for tutorials for SRM workflow basics. Thanks to all in advance. Anu.

  • WMV3Server plays avi files containing WMV3/9 video and MP3 audio

    WMV3Server To play avi files with WMV3/9 video and MP3 audio encoding on Mac OS X as of 2005-01-24 you will need: Mac OS X 10.2 or later WMV3Server Windows Media Player 9 for Mac OS X An .avi file containing WMV3 video and MP3 audio. Instructions: La

  • Runnable JAR from Eclipse with DLL

    Hi, Is it possible to export a runnable jar from Eclipse that includes and uses a dll? My simple application uses an 'external' API - JIntelliType - a jar file and a dll belongs to it. I can run the project fine from Eclipse, but I can't export it to

  • Flash Links in Safari

    I have a problem with Safari and SWFs. In Safari, if the user ctrl-clicks or cmd-clicks a link it opens the link in a new tab in the browser. This does not seem to work for SWFs that contain links. It works fine in IE7 and Firefox. Is there a work ar

  • How to change IMAQ ROI color while adjusting handles

    I have an application where a user must draw a rotated rectangle box around an object.  I'm using an color overlay to highlight the box, but when the user is adjusting the roi handles, the box color becomes gray.  The images i'm working with are gray