Sponsored Content
Top Forums Shell Programming and Scripting Create a dummy file in all directories that include a .jpg Post 302618177 by Davinator on Tuesday 3rd of April 2012 05:19:13 PM
Old 04-03-2012
Create a dummy file in all directories that include a .jpg

Hello. My latest project has me with the need for the following script. Basically, any directory that includes a .jpg file needs to also have a ".picture" file created (if it doesn't exist). Here's an example of what I need.

Code:
/mnt/user/Pictures/2011/Hawaii - 2011/.picture
/mnt/user/Pictures/2011/Hawaii - 2011/Hawaii.jpg
/mnt/user/Pictures/2012/Mammoth - family - 2012/Mammoth 001 - 2012.jpg

In this example, I want to recursively scan all directories in /mnt/user/Pictures/, and create the .picture file in any directory that has a .jpg file within it (/mnt/user/Pictures/2011/Hawaii - 2011/, for example, does not include a .jpg file). The only directory that would need the .picture file in this example would be /mnt/user/Pictures/2012/Mammoth - family - 2012/. This .picture file is an empty dummy file, and can created as simply as "echo > .picture".

I don't mind recreating the .picture file in each directory, regardless of if it already exists or not. I thought it might be cleaner to only create it if it's needed, but it's not that big of a deal to recreate it each time regardless.


Any thoughts on the code for this script? I started going down the path of using:
Code:
find /mnt/user/Pictures/ -name \*.jpg -print

... however, I quickly hit a brick wall after that.

Thanks for the help in advance!!
 

10 More Discussions You Might Find Interesting

1. SCO

Create dummy printer

On SCO Openserver we create a so called dummy printer that directs to /dev/null (we use this in our software to purge some stuff). Now I have SCO UnixWare 7.1.4, but I cannot create a dummy printer. I create the printer exactly as in Openserver by the Printer Manager, - Enter spoolname -... (1 Reply)
Discussion started by: p.vvugt
1 Replies

2. UNIX for Dummies Questions & Answers

Create directories from a sql file?

Hi, I have a sql file which has CREATE and INSERT commands in it. Basically, inside this file, a table will be created and the data will be inserted into the table. I was wondering if there is a way for me to create directories from this file? Thanks in advance (4 Replies)
Discussion started by: tezarin
4 Replies

3. Shell Programming and Scripting

check if multiple directories exist else create missing directories

Hi , I 'm trying to check if multiple directories exist on a server, if not create the missing ones and print " creating missing directory. how to write this in a simple script, I have made my code complex if ; then taskStatus="Schema extract directory exists, checking if SQL,Count and... (7 Replies)
Discussion started by: ramky79
7 Replies

4. Shell Programming and Scripting

How to create tgz file for all the directories in one time?

Hi, On server there is an one folder . which contains sub folder Eg - TEST folder contains test1, test2, execr ,tt (folder). also includes some text file like abc.txt psp.txt gg.log. here iwant to create tgz file for all the folders and file in one time. I know the command... (1 Reply)
Discussion started by: aish11
1 Replies

5. Linux

Create a dummy file even if the path is not exist

hi, i want to create a dummy file even if the path to that file is not exist as follows. suppose, in my working directory 2 files are there. and i create one more file which is exist as follows # pwd /home/satya # ls file1.txt file2.txt # echo dummy > /home/satya/file3.txt # ls... (3 Replies)
Discussion started by: snreddy_gopu
3 Replies

6. UNIX for Dummies Questions & Answers

Converting pdf to jpg in multiple directories?

Hi! On my Ubuntu I have thousands of files in a couple hundred directories. I'm trying to convert the pdf's to jpg's. I used this command in terminal: for fname in *.pdf; do convert $fname ${fname%.pdf}.jpg; doneIt works great but the problem is I have to run this in terminal for each... (2 Replies)
Discussion started by: martinsmith
2 Replies

7. Shell Programming and Scripting

Help with create multiple directories under diff file systems

Hi, Need help ...I want to create multiple directories in different /file systems using for loop..eg.../ORCL_data01/oradata/orcl/ctl. ../ORCL_data01/oradata/orcl/data. ../ORCL_data01/oradata/orcl/redo. Script :- ========= for dir in `ls -d... (8 Replies)
Discussion started by: Linux6.5
8 Replies

8. Shell Programming and Scripting

Create pdf of a jpg image in shell script

Dear Team, Can any one please let me know, if there is any way to create pdf of a Jpg image file in shell script. I work on Solaris, Korn Shell. Currently we are using sunpcl2pdf.exe to create PDF from PCL(Printer Control Language) files. But we are searching for some different way to... (2 Replies)
Discussion started by: Uttam Maji
2 Replies

9. Shell Programming and Scripting

Bash to create sub directories from specific file extension

In the bash below I am trying to create sub-directories inside a directory from files with specific .bam extensions. There may be more then one $RDIR ing the directory and the .bam file(s) are trimmed (removing the extension and IonCode_0000_) and the result is the folder name that is saved in... (2 Replies)
Discussion started by: cmccabe
2 Replies

10. UNIX for Beginners Questions & Answers

Create movie from jpg (or other picture format) file

hi linux expert is there any program for create movie file from pictures file (like jpg)? Many Thanks samad (1 Reply)
Discussion started by: abdossamad2003
1 Replies
IGREP(1)                                                      General Commands Manual                                                     IGREP(1)

NAME
igrep - search images for matching metadata SYNOPSIS
igrep [options] pattern files... DESCRIPTION
The igrep utility is invoked as follows: igrep [options] pattern filename... Where pattern is a POSIX.2 regular expression (just like the Unix/Linux grep(1) command), and filename (and any following names) specify images or directories that should be searched. An image file will "match" if any of its metadata contains values contain substring that are recognized regular expression. The image files may be of any format recognized by OpenImageIO (i.e., for which ImageInput plugins are available). Example: $ igrep Jack *.jpg bar.jpg: Keywords = Carly; Jack foo.jpg: Keywords = Jack test7.jpg: ImageDescription = Jack on vacation For a complete description, see /usr/share/doc/libopenimageio-dev/openimageio.pdf.gz. OPTIONS
--help Print help message -i Ignore upper/lower case distinctions -v Invert match (select non-matching files) -E Pattern is an extended regular expression -f Match against file name as well as metadata -l List the matching files (no detail) -r Recurse into directories -d Print directories (when recursive) -a Search all subimages of each file SEE ALSO iconvert(1), idiff(1), iinfo(1), iprocess(1), iv(1), maketx(1), oiiotool(1). AUTHOR
OpenImageIO was written by Larry Gritz and the other authors and contributors. This manual page was written by IRIE Shinsuke <irieshinsuke@yahoo.co.jp>, for the Debian project (and may be used by others). May 19, 2012 IGREP(1)
All times are GMT -4. The time now is 02:56 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy