Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Bash with problems related to files Post 302950777 by riccardo on Tuesday 28th of July 2015 03:22:15 PM
Old 07-28-2015
Wrench Bash with problems related to files

Hi unix people, i'm really a newbie and i've created a small bash to process some picture with ImageMagick.
I have just some issue and i think this script, if we can help me to correct in right way, could be useful!

Basically i have a Eyefi Card who puts files into a folder called "picture"
(sorry i must use cygwin cause last version EyeFi does'nt work under linux environemet)
i need take only the last 25 pictures from that,rename and put in a separate folder (i don't know how to do it so i put on same Smilie )
after i process the dimension, add the watermark and copy on different folder.

here the code:
Code:
#!/bin/bash
while : 
do
    echo "Foto Su Eyefi build 1.9 del 28.07.2015 ---- Riccardo Galardi"
    sleep 2s
    echo "VAI ALLA CARTELLA PICTURES"
    sleep 2s
	cd /
    cd cygdrive/c/PICTURES	
	echo "--------OK---------"
    echo "Prendo gli ultimi 25 files e li sovrascrive nella stessa cartella PICTURES con numerazione progressiva"
    sleep 2s
	find $DIR -type f -printf "%T@ %p\n" | sort -n | cut -d' ' -f 2 | tail -n 25 | gawk 'BEGIN{ a=1 }{ printf "mv \"%s\" %04d.JPG\n", $0, a++ }' | bash
    echo "--------OK---------"
	sleep 2s
	echo "Riduco le dimensioni a 1920 lato lungo"
    mogrify -resize 1920x1920 *.jpg
	sleep 2s
	echo "--------OK---------"
	echo "Inserisci il Logo sulle foto"
	mogrify *.jpg -gravity center -draw "image over 0,0 0,0 'Back.png'" *.jpg
	echo "--------OK---------"
	sleep 2s
    echo "Copia le foto elaborate sul drive Z"
    cp *.JPG /cygdrive/z
	echo "--------OK---------"
	sleep 2s
    echo "attendo 10 sec"
	echo "Press [CTRL+C] to stop.."
    sleep 10s
	
done

my biggest problem is: how i can exctract only the pictures and not the other files inside the folder? (often my watermark is taked as picture...and processed also if it's in a separate folder)
and how can i put only the last 25 files on a separate folder?

Thank you very much, really apreciate any help.... and hope my script could be interesting to someone else who use EyeFi card
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

problems with bash

Hi. I'm really a newbie trying to make my new Mac (OS 10.3) run some science programs under the X11 environment. I have been trying to install GDE2.2. In short, after several attempts I came to the URL http://www.mutatedmonkeys.com/factslog/archives/000830.html. And I thought that was my lucky... (0 Replies)
Discussion started by: tribu13
0 Replies

2. Shell Programming and Scripting

Problems writing bash script to unzip files

I'm getting the following errors when I try to write a script to unzip some zip files. When I use the free trial copy of the commerical winzip program, however, they work fine. When I use -l or -t on unzip it indicates no errors. When I use the -o switch interactively from the bash command line it... (1 Reply)
Discussion started by: siegfried
1 Replies

3. Shell Programming and Scripting

cd problems in bash

Hi, I'm having problems with the "cd" command in bash not changing directories. From what I've read, I've gathered that scripts are child processes and can't change the directory of their parent process. How do I get around this problem? Thanks, Eric (2 Replies)
Discussion started by: Kweekwom
2 Replies

4. Shell Programming and Scripting

Generating an xml having information related to files in the directory

Hi all, Have to generate an xml having information related to files in the directory Suppose i have file file1.xml (datafile) file2.xml (datafile) file3.xml (metafile) Now i need to generate an xml in the format >> <?xml version="1.0" encoding="UTF-8"?> <AuditFile Version="2.0">... (8 Replies)
Discussion started by: abhinav192
8 Replies

5. Shell Programming and Scripting

How to compare 2 files & get only few columns based on a condition related to both files?

Hiiiii friends I have 2 files which contains huge data & few lines of it are as shown below File1: b.dat(which has 21 columns) SSR 1976 8 12 13 10 44.00 39.0700 70.7800 7.0 0 0.00 0 2.78 0.00 0.00 0 0.00 2.78 0 NULL ISC 1976 8 12 22 32 37.39 36.2942 70.7338... (6 Replies)
Discussion started by: reva
6 Replies

6. Solaris

what is the use of each login related files present in users home directory

# ls -l total 10 -rw-r--r-- 1 dummy2 other 140 Jun 19 21:37 local.cshrc -rw-r--r-- 1 dummy2 other 136 Jun 19 21:37 local.cshrc~ -rw-r--r-- 1 dummy2 other 157 Jun 19 21:37 local.login -rw-r--r-- 1 dummy2 other 178 Jun 19 21:37 local.profile... (6 Replies)
Discussion started by: chidori
6 Replies

7. UNIX for Dummies Questions & Answers

unix commands related to ftp of files..

Hi, I am new to unix , I was planning to write a script that will FTP files to destination folder. , Please guide me what are the various networking commands that unix will help in this ftp process..?:confused: (1 Reply)
Discussion started by: rahul125
1 Replies

8. Shell Programming and Scripting

Help related to Script to move files depending on config values

Hi All, I am new to Unix scripting, I have requirement where I need to read the key value pair from config file. Sample Config file: Key(File Pattern) Value(File Directory location) test /Users/Bkumar/Downloads/testdir prod ... (1 Reply)
Discussion started by: sbpkumar7
1 Replies

9. Shell Programming and Scripting

Problems with 'for' in bash

I am trying to run this small script but I got some errors #!/bin/sh set event_list = "17 20 21" for event in `($event_list)` echo Evento $event - Tarro end Thank you so much!!! (2 Replies)
Discussion started by: JuanC_Ber
2 Replies

10. Shell Programming and Scripting

Question related to bash. Your help needed.

Dear Team, i have one question related to automation of adding new users based on txt file. Here we go: I have data.txt file which shows: bang dang benc One by one, after pressing enter. And now, I need scirpt which will add those users with home directory hidden within the file... (7 Replies)
Discussion started by: protos27
7 Replies
MRENAME(1)						      General Commands Manual							MRENAME(1)

NAME
mrename - program to rename files SYNOPSIS
mrename 'pattern' prefix [option] DESCRIPTION
This manual page documents briefly the mrename command. This manual page was written for the Debian GNU/Linux distribution because the original program does not have a manual page. mrename is a tool for easy and automatic renaming of many files. The 'pattern' is the pattern to search files to rename (quoted to avoid that bash resolve it), and prefix is the prefix that will be added to the name of each file. The two alternative options for copying or moving files in the new name are explained below. All parameters are needed, and you have to stay and launch the script in the same direc- tory of the files to be renamed. The program should be able to write in this directory. OPTIONS
There are only the following three options. -c The option -c will copy each file with the new filename. -m The option -m will move each file in the new filename. -h Display help. EXAMPLE
If you have a directory with two jpeg images prof.jpg and forp.jpg and you want to add them a prefix like item0, item1 etc.. (that is item0prof.jpg, item1forp.jpg etc..) do this: cd /path/to/the/images mrename '*.jpg' item -c to copy each matching file into another with the new name mrename '*.jpg' item -m to rename each file without keeping a copy with the previous name Word-Wide-Web: http://alfalinux.sourceforge.net/mrename.php3 AUTHOR
: Giancarlo -rofus- Erra e-mail: rofus@mindless.com This manual page was written by Dr. Guenter Bechly <gbechly@debian.org>, for the Debian GNU/Linux system (but may be used by others). It is distributed under the GPL just like mrename itself. October 22, 2000 MRENAME(1)
All times are GMT -4. The time now is 11:45 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy