Sponsored Content
Top Forums Shell Programming and Scripting Synchronize pictures & resize at the same time Post 302445752 by agama on Monday 16th of August 2010 07:54:54 PM
Old 08-16-2010
Quote:
Originally Posted by Joeba
thanks you both! Smilie

some questions:
- I don't know the mk command, is mkdir also good?
- shouldn't it be: if [[ ! -d $targetd ]] (exclamation mark) because needs to create dir when it doesn't exist
- same for the file check, shouldn't it be with exclamation mark?
- added quotes around mk -p "$targetd" because had issue with spaces in dir name
How embarassing. Yes, mkdir. I use plan 9's make which is mk, so that is what my fingers like to type.

Also, yes ! -d; another typo I hit $ instead of ! from the looks of my original post.

I cut/pasted the original script posted by rdcwayx and didn't even look to find the -f mistake. Yes, a bang in front of it to copy only the files that don't exist on the target (otherwise you'll overlay them with the smaller images).

I abhor filenames with spaces for just that reason. Quoting is the right thing to do if you don't have a choice about the filenames.

Quote:
when I run the script with a test directory:
test (dir)
_sub test (dir)
___testfile
_testfileroot

I get the following in the target dir
test2 (dir)
_sub test (dir)
___empty!
_testfileroot (dir)
___testfileroot

so think I've made a small error somewhere?
Not sure at the moment. I'll copy out the script you posted and try it here and add something if I see what is wrong.

---------- Post updated at 19:54 ---------- Previous update was at 19:35 ----------

I think the problem stems from the assumption by $(STR%/*} that STR contains a path. It doesn't for files that sit in the top level directory. Here's the whole script that I ran which created the right directories, and copied the things that weren't in the target:

Code:
#!/usr/bin/env ksh

NAS=$PWD/2000     # my test directories
XBMC=$PWD/2001

find $NAS -type f | while read file
do
  STR=${file##$NAS/}
        if [[ $STR == */* ]]        # strip trailing component only if STR has a path rather than just a filename
        then
                targetd=$XBMC/${STR%/*}               # get the target dir by chopping off the basename
        else
                targetd=$XBMC    # if STR is just a filename, the target is just XBMC
        fi

  if [[ ! -d $targetd ]]
  then
    mkdir -p $targetd
  fi

  if [[ ! -f $XBMC/$STR ]]
  then
     cp $file $XBMC/$STR
     echo Convert $XBMC/$STR                 # replace by the real convert command
  else
        echo "target existed, not copied: $file"  # positive confirmation during testing that it didn't try to copy a file
  fi
done

Have a go with the changes to test $STR for a slant and see how that works.
 

8 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

How do I send pictures in email?

I know how send a html page through mailx, but how do I show the pictures(gif,jpeg,etc.) in the email? (4 Replies)
Discussion started by: Thomas
4 Replies

2. Programming

curses & window resize issues

I am writing a program to display a database to the screen(xterm) and want to allow the window resize signal to increase/decrease the amount data that is displayed. I have a signal handler function for catching the SIGWINCH event and calling a function to reallocate the space for the windows... (0 Replies)
Discussion started by: kwaz
0 Replies

3. UNIX for Advanced & Expert Users

Solaris 9: How to set time/Synchronize

Hi, I have 4 solaris 9(32-Bit) Sparc machines on the same subnet. All 4 of them have different times( off by 10-15 mins). I need to synchronize all 4 of them. Please advise what I should do to sync them to the proper time, and with each other. Thanks (3 Replies)
Discussion started by: 0ktalmagik
3 Replies

4. Shell Programming and Scripting

HP-UX & need help with time

I use HP-UX & need help with time. I use a script to create a date stamp: /bin/date "+%m%d%H%M" to get: 12080826. I need a way to use the "touch -t" command to create a file with a timstamp 30 minutes prior to that stamp. (12080756) Can anyone help? (9 Replies)
Discussion started by: obrien2003
9 Replies

5. AIX

Synchronize time on several AIX servers ?

Hi, I want to synchronize time on several AIX servers - I don't want to set very precise time value, but I want all the servers to have same time value. How do I do that ? thanks Vilius (2 Replies)
Discussion started by: vilius
2 Replies

6. Shell Programming and Scripting

Convert Epoch Time to Standard Date and Time & Vice Versa

Hi guys, I know that this topic has been discuss numerous times, and I have search the net and this forum for it. However, non able to address the problem I faced so far. I am on Solaris Platform and unable to install additional packages like the GNU date and gawk to make use of their... (5 Replies)
Discussion started by: DrivesMeCrazy
5 Replies

7. Programming

DATE & TIme

Can we select the datetime from oracle database in “hhmmssnnnccyymmdd” format ? please help to solve this..... (2 Replies)
Discussion started by: Sanal
2 Replies

8. Shell Programming and Scripting

How to find & auto resize images?

I need a command or mini scripts that can find certain type of images file recursively from the current dir with files of minimum 736 width and resize them by "736 max width, relative height" and replace the source files. I currently have GD installed but can also install Imagemagick if needed, I'm... (5 Replies)
Discussion started by: Frozen77
5 Replies
PCOMPOS(1)						      General Commands Manual							PCOMPOS(1)

NAME
pcompos - composite RADIANCE pictures. SYNOPSIS
pcompos [ -h ][ -x xres ][ -y yres ][ -b r g b ][ -lh h ][ -la ] [ -t min1 ][ +t max1 ][ -l lab ][ =SS ] pic1 x1 y1 .. or pcompos [ -a ncols ][ -s spacing ][ -o x0 y0 ][ options ] pic1 pic2 .. DESCRIPTION
Pcompos arranges and composites RADIANCE pictures and sends the result to the standard output. Each input picture must be accompanied by an anchor point (unless the -a option is used, see below). This anchor point is the usually position of the picture's left lower corner in the final output, but can be changed for individual pictures with an =SS option, where S is one of '-', '+' or '0', indicating the minimum, maximum or center of the image, respectively. (For example, =+- would indicate the anchor is relative to the right lower corner, and =-0 would indicate the anchor is relative to the center of the left edge.) Negative anchor coordinates result in the input being cropped at the origin. By default, the size of the output picture will be just large enough to encompass all the input files. By specifying a smaller dimension using the -x and -y options, input files can be cropped at the upper boundary. Specifying a larger dimension produces a border. The -b option specifies a background color to appear wherever input files do not cover. The default value is black (0 0 0). The -h option may be used to reduce the information header size, which can grow disproportionately after multiple runs of pcompos and/or pcomb(1). If input files overlap, later pictures will overwrite earlier ones. By default, input files are copied unconditionally within the output boundaries. The -t option specifies a lower threshold intensity under which input pixels will not be copied to the output. The +t option specifies an upper threshold. These options are useful for cutting around irregular boundaries in the input. The -l option can be used to specify a label for a specific picture, which will be given a height determined by the -lh option (default 24 pixels) and placed in the upper left corner of the picture. This label is generated by the program psign(1). The -la option instructs pcompos to label each picture automatically by its name. This is particularly useful in conjunction with the -a option for producing a catalog of images (see example below). The -l option may still be used to override the default label for a picture. The -a option can be used to automatically compute anchor points that place successive pictures next to each other in ncols columns. The ordering will place the first picture in the lower left corner, the next just to the right of it, and so on for ncols pictures. Then, the next row up repeats the pattern until all the input pictures have been added to the output. If the pictures are of different size, pcompos will end up leaving some background areas in the output picture. There will also be an unfinished row at the top if the number of pictures is not evenly divided by ncols. The -s N option will cause each image to be separated by at least N pixels. The -o x0 y0 option specifies a nonzero anchor point for the bottom left image. The standard input can be specified with a hyphen ('-'). A command that produces a RADIANCE picture can be given in place of a file by preceeding it with an exclamation point ('!'). EXAMPLE
To put a copyright label at the bottom of a picture: psign Copyright 1987 | pcompos inp.hdr 0 0 +t .5 - 384 64 > out.hdr To make a catalog of images separated by white 10-pixel borders: pcompos -la -a 4 -s 10 -b 1 1 1 dog*.hdr > alldogs.hdr NOTES
Since there is a limit to the number of open files and processes, large collections of images must be created in stages. Even if the sys- tem limit on open files is large, pcompos places an artificial limit of 1024 on the number of open files and/or processes. AUTHOR
Greg Ward SEE ALSO
getinfo(1), pcomb(1), pfilt(1), psign(1), rpict(1) RADIANCE
12/18/97 PCOMPOS(1)
All times are GMT -4. The time now is 09:11 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy